Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.warn
andconsole.error
with the corresponding method oflogger
(in the library, not yet in the CLI)options
argument as the first argument toinit()
(If the first argument is a function, it will still be interpreted ascallback
)options
, a propertyloglevel
can 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
loglevel
will 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