npm install @emartech/key-value-to-json-log
or you can use it through
npx -p @emartech/key-value-to-json-log -c '<YOUR_PROCESS_TO_LOG> | key-value-to-json-log'
Just pipe your process into the
node server/process/web | key-value-to-json-log
And now all incoming logs will be converted and output to
process.stdout (or where @emartech/json-logger is logging).
During the transformation the following rules are applied. Please refine your alerts!
The namespace (
type) will be logged as
name, as the event's name (
event) will be
The level of your log (previously
result) is converted to a log level (
level) by @emartech/json-logger.
key-value-to-json-log uses the following mapping:
- by default, everything is
Even if the log message has a timestamp in it, it will be truncated and @emartech/json-logger will add its own
All log keys will be converted to snake_case.
key-value-to-json-log detects if an Error had been logged and will transform the incoming
stack keys by prefixing with
error_ as it would be done by @emartech/json-logger if you would log an Error with
All incoming number values will be converted to
int in the JSON output.
May be freely distributed under the MIT license.
Copyright (c) 2018 Emarsys Technologies Ltd. and other contributors