-
-
Notifications
You must be signed in to change notification settings - Fork 206
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
feat: move to winston logger #67
Conversation
Pull Request Test Coverage Report for Build 426057167
💛 - Coveralls |
* Use setup() instead of module() * Allow config to be passed into setup() * Add `enable` config setting * Add `level` config setting * Add `logTofile` config setting * Add `filename` config setting * Adjust formatting to requirements
* Added 3 example usages to ZwaveClient.js
* Use module() again for creating the logger * Add setup() method to the logger * Revert module name back to original value
@robertsLando the previous debug-based logging is now fully replaced with the new winston-based logging module. The only thing that is intentionally left is integration into the UI and control using settings.json which requires some discussion about the best approach to propagate logging config changes to the module loggers. |
* Add automated tests for all functionality * Add setupAll() to change config for loggers of all modules * Code cleanup
@robertsLando after some more work I was able to resolve all open questions and handle the logging configuration in app.js (see But there's a side-effect I observed I was not yet able to solve yet: So from my POV the PR is ready for review. |
@AlCalzone Do you know if this could cause some conflict with your loggers? |
@ahochsteger Review done. Feel free to squash and merge if you are done here 😄 |
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.
@ahochsteger I would like a cleaner output format. The color should be applied only to level and the timestamp could be gray. It is much pretty to read
I also think you have missed |
8eb5fc4
to
17310d6
Compare
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.
LGTM
This PR unifies the logging across zwavejs2mqtt using winston.
Usage:
Conditions & Requirements:
<timestamp> <level> <moduleName/label>: <logMessage>
(e.g.2020-12-04 09:06:32.568 INFO APP: Zwave2MQTT Version 0.0.0
)ZWAVE
MQTT
GATEWAY
STORE
HASS
HTTP
APP
settings.js
settings.js
using the existing optionslogLevel
andlogToFile
logEnabled
tosettings.js
and UIRequired changes to the existing codebase:
The following files are affected and show the existing logging implementation that should be migrated to the new logging module:
lib/ZwaveClient.js
(uses debug) --> winstonZWAVE
moduleapp.js
(uses debug & morgan) ---> winstonHTTP
andAPP
moduleslib/jsonStore.js
(uses debug) ---> winstonSTORE
module (need to think about this, we could use console otherwise)lib/Gateway.js
(uses debug) ---> winstonGATEWAY
and (maybe)HASS
moduleslib/MqttClient.js
(uses debug) --> winstonMQTT
modulelib/SocketManager.js
(uses debug) --> winstonSOCKET
modulelib/debug.js
(uses debug) ---> Obsolete, replaced withlogger.js