electron-log
electron-log copied to clipboard
Allow to reinitialize console transport
Currently console.js
in electron-log makes references to console functions (e.g console.log
, etc.) during module initialization (source).
This can lead to problems if the application (or its libraries) then make replacements of these functions.
For instance, the Sentry library replaces (wraps) console functions when it is initialized (call to Sentry.init
) (source) so it can intercept all log messages and report them to the Sentry service. As electron-log
keep reference to the original/unwrapped functions, all messages created with electron-log
are invisible to Sentry.
As a consequence this makes electron-log
unusable for projects that uses Sentry or similar libraries.
It would be nice to have a way to tell electron-log
to reinitialize its console transport.
Or (maybe better) console.js
would be partially rewritten so it does not keep references to console functions at module initialization and instead uses the console
object again each time its methods need to be called.
Thanks for any feedback
I'll think about it for v5 release.
We would also like to use it in combination with Sentry... @clemp6r did you find a workaround?
@stoefln No, we just postponed integration of log files for now.
Any update? Is there a possibility we have a quick workaround until v5 is out?
See my PR that fixes the issue: https://github.com/megahertz/electron-log/pull/330
Thank you @clemp6r . Unfortunately, I can't approve this PR. While it solves an issues with Sentry, it breaks the following case: Object.assign(console, log.functions);
. Please let me know if I missed something.
Anyaway, I'm going to publish v5 beta in the next 2-3 weeks
Ok, no problem, I will close the PR and keep the change for myself.
In v5 console transport has writeFn
which allows to override a console call.