2.1.1 • Published 2 years ago
logslot v2.1.1
logslot
A tiny logger that outputs json at runtime and pretty logs during development
Example Usage
const logslot = require('logslot');
logslot('myapp.test.one').error('some error', { extraThings: 1 })
logslot('myapp.test.one').warn('a warning', { extraThings: 2 })
logslot('myapp.test.one').info('for your info', { extraThings: 3 })
logslot('myapp.test.one').verbose('lots of detail', { extraThings: 4 })
logslot('myapp.test.one').debug('for the devs', { a: 1, b: 2 })
logslot('myapp.test.two').info('different namespace', { extraThings: 10 })
Output (json)
["23/02/2021 10:57:37 pm","myapp:test:one","ERROR","some error"]
["23/02/2021 10:57:37 pm","myapp:test:one","WARN","a warning"]
["23/02/2021 10:57:37 pm","myapp:test:one","INFO","for your info"]
["23/02/2021 10:57:37 pm","myapp:test:two","VERBOSE","lots of detail"]
["23/02/2021 10:57:37 pm","myapp:test:two","DEBUG","for the devs",{"a":1,"b":2}]
["23/02/2021 10:57:37 pm","myapp:test:two","INFO","different namespace",{"extraThings":10}]
Log level
You can set the log level from an environment variable:
LOGSLOT_LEVEL=debug
Or with code:
const logslot = require('logslot');
logslot.setLogLevel('debug');
Output (pretty)
LOGSLOT_FORMAT=pretty
License
This project is licensed under the terms of the MIT license.