Simple logger for NodeJS
What does it do?
This logger simply uses the Javascript console
object to log messages in JSON format. The JSON will be transformed to a string by simply running JSON.stringify
on it. If you log a text message the format will be:
If you log a JSON serializable object the format will be:
Installation
npm install --save elbstack-logger
Usage
const Logger = ;const logger = 'sample-app-id' '1.0.0' LoggerLOG_LEVEL_INFO;
Log level hierarchy
LoggerLOG_LEVEL_DEBUGLoggerLOG_LEVEL_INFOLoggerLOG_LEVEL_WARNLoggerLOG_LEVEL_ERRORLoggerLOG_LEVEL_FATAL
Usage with text messages
logger;
Usage with JSON serializable objects
logger;
Usage with both
The logger simply accepts multiple arguments. All object type arguments will be merged straight away into the logged JSON from the right to the left. All arguments of other types will be merged to one string divided by spaces. That means that if you would do the following function call:
logger;
Then the result will be: