megahertz / electron-log

Simple logging module Electron/Node.js/NW.js application. No dependencies. No complicated configuration.
MIT License
1.3k stars 127 forks source link

Filter Multiple Log Levels #373

Closed monica-muthukumaran closed 10 months ago

monica-muthukumaran commented 10 months ago

Hi, I see that

logger.transports.file.level = "error";
logger.transports.console.level = "error";

will filter out that specific level. But is there a way which i filter out few levels only.

For example "error" and "verbose" only

megahertz commented 10 months ago

When you set the "warn" level it also includes any upper levels ("error" and "warn" in that case). If you would like to include different levels such as "error" and "verbose", you can write a custom hook for that.

monica-muthukumaran commented 10 months ago

Thank you

monica-muthukumaran commented 10 months ago

Also, Can you please help me on understanding the hierarchy of the log levels.

megahertz commented 10 months ago

There is nothing special. There are five levels: error, warn, info, verbose, debug, silly. Each next level has a lower priority. So, when a log level is set for a transport it means to process logs which level is >= the specified level