-
I'm having trouble figuring out how to parse these debug logs in their current "human" readable format with indentations, etc -- this would be much easier to filter through if the data was in json format, or at least in a format where all the data is contained within a single line. I was hoping there might be a configuration switch somewhere to enable json output, or at least some kind of greppable format? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
Customizing the logging output is done by installing log transports. There are some default ones, including JSON, bundled with Z-Wave JS, or you can create your own. I think usage of these log transports is intended for application developers, not end users. You probably want to make a feature request to the application you're using (e.g. Z-Wave JS UI) to support this functionality, unless you're a developer yourself. The log transport configuration is part of the driver options, which most applications don't give you direct access to. Popular applications like Z-Wave JS UI or the Home Assistant add-on aren't currently capable of configuring custom log transports. I experimented with the bundled JSON transport at one point, and had a configuration module that looked something like this: const logjson = require('@zwave-js/log-transport-json')
function getLogConfig() {
jsonlog = new logjson.JSONTransport()
jsonlog.stream.on('data', console.log)
return { transports: [ jsonlog ] };
}
module.exports = {
logConfig: getLogConfig(),
}; It outputs the JSON formatted logs to the console. There is probably a better way to do this (I'm no JS expert), and this is limited to console output only. The node-red-contrib-zwave-js project provides a real example of using custom log transports: https://github.com/zwave-js/node-red-contrib-zwave-js/blob/e9bf1697c60ae5d0cc8b7098b779947056674164/zwave-js/zwave-js.js#L238 |
Beta Was this translation helpful? Give feedback.
-
I think it would be a nice enhancement if the driver configuration would allow switching between any of the official extra log formats, e.g. JSON or logfmt output, which a simple option, instead of requiring code to enable the transports, while supporting the existing file/console output and log rotation. Then all applications could take advantage of the different formats. |
Beta Was this translation helpful? Give feedback.
Customizing the logging output is done by installing log transports. There are some default ones, including JSON, bundled with Z-Wave JS, or you can create your own.
I think usage of these log transports is intended for application developers, not end users. You probably want to make a feature request to the application you're using (e.g. Z-Wave JS UI) to support this functionality, unless you're a developer yourself. The log transport configuration is part of the driver options, which most applications don't give you direct access to. Popular applications like Z-Wave JS UI or the Home Assistant add-on aren't currently capable of configuring custom log transports.
I experimented with the …