iog
v1.6.0
Published
Save your logs on disk, so simply.
Downloads
9
Maintainers
Readme
iog
Save your logs on disk, so simply.
Installation
npm install --save iog
Example
const Iog = require('iog');
const logger = new Iog('my-module-name', {
onLog(body, type) {
console.log(body, type)
}
});
logger.write('my log info');
logger.write({
also: {
you: 'want, for example an object'
}
});
Log format
this produces
logger.write('my log info');
this
CONTEXT: my-module-name
DATE: 2018-03-03 20:14:12:367
TYPE: log
BODY:
my log info
---------------------------------------------------------------------------------------
this produces
let obj = {
error: "undefine is not defined",
other: {
meta: "a meta"
}
};
logger.write(obj);
this
CONTEXT: my-module-name
DATE: 2018-03-03 20:14:12:367
TYPE: log
BODY:
{
"error": "undefine is not defined",
"other": {
"meta": "a meta"
}
}
---------------------------------------------------------------------------------------
API
Iog
Kind: global class
new Iog(contextName, [opts])
Iog instance
iog.pause() ⇒ Iog
Pause log writing
Kind: instance method of Iog
iog.resume() ⇒ Iog
Resume log writing
Kind: instance method of Iog
iog.write(msg, [type], [show])
Write log
Kind: instance method of Iog
iog.error(msg)
A wrapper of write that set type to "error"
Kind: instance method of Iog
iog.warn(msg)
A wrapper of write that set type to "warn"
Kind: instance method of Iog
iog.info(msg)
A wrapper of write that set type to "info"
Kind: instance method of Iog
iog.trace(msg)
A wrapper of write that set type to "trace"
Kind: instance method of Iog
License
Iog is open-sourced software licensed under the MIT license
Author
Fabio Ricali