-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added loging level through mqtt #110
Conversation
lib/controller.js
Outdated
} else if (option === 'log_level') { | ||
const level = message.toString().toLowerCase(); | ||
if (allowedLogLevels.includes(level)) { | ||
logger.warn(`Switching log level to '${level}'`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a warning, I think logger.info
fits better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you set this to info, but you set log level to warn you miss the message that log level has changed.
If it is acceptable happy to change it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
lib/controller.js
Outdated
logger.transports.console.level = level; | ||
logger.transports.file.level = level; | ||
} else { | ||
logger.error(`Could not set log level to '${level}'`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice to log the possible values. e.g.
logger.error(`Could not set log level to '${level}', allowed levels are ${allowedLogLevels}`);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
It seems that even if https://github.com/visionmedia/debug is capable of dynamic enable/disable, it's not possible to do it across all because dependencies have debug pinned to old version without support :( I will try a few more workarounds but I doubt I will be in luck |
Is this needed for Allow setting log level for dependencies (where possible, like #81 (comment))? I think this is a 'nice to have'. |
I'll move debug messages in zigbee2mqtt to logger and let the rest use visionmedia/debug. Any reason for using debug here? |
@ciotlosm all debug within zigbee2mqtt can be replaced by logger.debug |
Will look to move debug messages for dependencies into a separate PR if I find a workaround. |
@Koenkk Updated also documentation. Can you please have a look? Want me to squash messages into a single commit? |
Did a rebase on top of latest master |
Thanks! |
Perfect. Should I close the logging issue? |
Added loging level through mqtt
Added loging level through mqtt
Just logging entity (not libraries) and no documentation added in this PR. Couldn't figure out how to print nicely log level as didn't want to have it as "critical" the information that you're switching log level.
Implements #81 parially
logger
when receivedDEBUG
env variable