Feature: Loglevel#159
Conversation
|
Thanks! This looks like a good idea, and it's great it's not using another library for the logging. My concern is that the Espruino IDE (espruino.com/ide / https://github.com/espruino/EspruinoWebIDE) uses this too, but I think that merging this would break that since it doesn't use I think it would also break espruinotools (https://github.com/espruino/EspruinoAppLoaderCore/blob/893c2dbbe5a93fbb80d035a695663b4f4cca8875/lib/espruinotools.js) built from EspruinoTools with https://github.com/espruino/EspruinoWebIDE/blob/master/extras/create_espruinotools_js.sh Would you be able to move the logger declaration into |
|
Ah, I see! Sure, I'll see what I can do. |
I'm not sure if this is something you want in the repo, if not, you can just close the PR.
This PR will:
console.log,console.warnandconsole.errorwith the corresponding method oflogger(in the library, not yet in the CLI)optionsargument as the first argument toinit()(If the first argument is a function, it will still be interpreted ascallback)options, a propertyloglevelcan be set--loglevel [number]that gets passed down toinit()if definedLog levels:
0= Log errorslogger.error()1= Log errors and non-debug messageslogger.error(),logger.log()2= Log errors, non-debug messages and warningslogger.error(),logger.log(),logger.warn()3= Log errors, non-debug messages, warnings and debug messages (default)logger.error(),logger.log(),logger.warn(),logger.debug()The default
loglevelwill log everything, as it was previously. I tried to the best of my ability to use the most suitable logger method for each existing message, but there could be some messages that you may want to use another method for, I'll leave it for you to decide.Examples:
# CLI espruino --loglevel 0