Skip to content
This repository was archived by the owner on May 16, 2023. It is now read-only.

emartech/node-key-value-to-json-log

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@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 be info (30)
  • error will be error (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

About

No description, website, or topics provided.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •