Closed MikeRatcliffe closed 1 month ago
I agree, it makes sense to make an example of output processing. In v5 a new property transport.transforms
was introduced for that. I have added it to type definitions. But I want to play a bit more with it and add the corresponding documentation when I'm sure the public interface is good enough.
As for toJSON
function, it just follows the standard convention when it returns a JSON representation of some object, it doesn't have to be a string.
It really helped me. Sometimes, it may be necessary to add chalk.level = 3 to make colorization work fine.
I've been playing around with
5.0.0-beta.25
and found very little about customizing the output in this version. After going through the source, I have created a more verbose example to help others.The only strange thing is that your
toJSON()
method inelectron-log/src/main/transforms/object.js
returns an object, rather than JSON. It removes cyclic references so thatJSON.stringify()
can safely handle them, but the method name should probably be changed.Renderer
This is my
logger.js
file. It initializes the log and keeps the format simple. Most importantly with this setup, the output fromconsole.log()
,console.error()
etc. in the renderer process appear in both DevTools and the terminal output:Main Process
The log customization in the main process is more verbose, but simple to customize.
global.logHome
andglobal.logLevel
need to be set first: