@emartech/key-value-to-json-log
v2.2.0
Published
This tool is written to convert all logs generated by [logentries-logformat](https://www.npmjs.com/package/logentries-logformat) in a process to be able to use and log with [@emartech/json-logger](https://www.npmjs.com/package/@emartech/json-logger).
Downloads
66
Maintainers
Keywords
Readme
@emartech/key-value-to-json-log
This tool is written to convert all logs generated by logentries-logformat in a process to be able to use and log with @emartech/json-logger.
Installation
npm install @emartech/key-value-to-json-log
or you can use it through npx
npx -p @emartech/key-value-to-json-log -c '<YOUR_PROCESS_TO_LOG> | key-value-to-json-log'
Usage
Command Line
Just pipe your process into the key-value-to-json-log
bin.
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).
Transformation rules
During the transformation the following rules are applied. Please refine your alerts!
Namespace/eventName
The namespace (type
) will be logged as name
, as the event's name (event
) will be action
.
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
debug (20)
success
will beinfo (30)
error
will beerror (50)
Timestamp
Even if the log message has a timestamp in it, it will be truncated and @emartech/json-logger will add its own time
.
Key format
All log keys will be converted to snake_case.
Exception/Error
key-value-to-json-log
detects if an Error had been logged and will transform the incoming name
, message
, code
and stack
keys by prefixing with error_
as it would be done by @emartech/json-logger if you would log an Error with logger.fromError()
.
Numbers
All incoming number values will be converted to float
/int
in the JSON output.
License
May be freely distributed under the MIT license.
Copyright (c) 2018 Emarsys Technologies Ltd. and other contributors