timtam-logger
v2.1.2
Published
logger for node.js
Downloads
8
Readme
timtam logger
Installation
$ npm install timtam-logger
API
constructor
options
The options for logger, default: {"app": "timtam", "timestamp": true, "maxLength": 900, "level": 3}
const Logger = require('timtam-logger');
const logger = new Logger({
app: 'my-app',
});
set
Set the value for options
k
The key of value or data to setv
The value
const Logger = require('timtam-logger');
const logger = new Logger({
app: 'my-app',
});
logger.set({
app: 'new-app',
});
logger.set('maxLength', 1000);
add
Add transport for logger
type
Transport type or uri for transportopts
The options for transport
const Logger = require('timtam-logger');
const logger = new Logger({
app: 'my-app',
});
logger.add('udp://127.0.0.1:5001');
logger.add('console');
logger.add('udp', {
host: '127.0.0.1',
port: 4012,
});
remove
Remove transport from logger
transport
The transport
const Logger = require('timtam-logger');
const logger = new Logger({
app: 'my-app',
});
const udpTransport = logger.add('udp://127.0.0.1:5001');
logger.remove(udpTransport);
logger.add('console');
log info warn error debug
The log function for logger
const Logger = require('timtam-logger');
const logger = new Logger({
app: 'my-app',
});
logger.add('console');
logger.info('my test');
wrap
Wrap the function of target to use logger
target
The target to wrapfns
The function to wrap, default is 'log', 'info', 'warn', 'error', 'debug'
const Logger = require('timtam-logger');
const logger = new Logger({
app: 'my-app',
});
logger.add('console');
logger.wrap(console);
console.info('my test');
before after
Use to insertBefore(insertAfter) some content to the log
param
The insert message string or function to get the insert message
const Logger = require('timtam-logger');
const logger = new Logger({
app: 'my-app',
});
logger.add('console');
logger.after('--end');
logger.after(() => '--start');
License
MIT