treacle
v0.2.0
Published
A simple logging framework. File logging and automatic rotation.
Readme
webn
A simple logging framework. File logging and automatic rotation.
How to use
Import, create a logger and then log to it.
import treacle from 'treacle'
const log = treacle()
log('hello!') // will log 'hello!' with a timestampIf you want to add a prefix to the output, use a subfunction:
import treacle from 'treacle'
const log = treacle()
log.error('something went wrong!') // will log '[ERROR] something went wrong!' with a timestampAll this will be logged to files. log.log is the standard log file, .error() and .fatal() will be logged to error.log. A special file called shutdown.log will hopefully log the reason for shutdown, when that happens.
Config
Of course this can be changed. treacle accepts a config object like so:
const log = treacle({
logDir: './log',
flushInterval: 3_000,
files: [
{
main: 'error',
rotations: 100,
routes: [
'error',
'fatal'
]
},
],
shutdownLog: 'shutdown.log',
})These are the default settings, but they can be changed to anything you like.
BTW
It's pronounced "trickle" to avoid confusion with a foodstuff.
