$ npm install timtam-logger
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 the value for options
-
k
The key of value or data to set -
v
The value
const Logger = require('timtam-logger');
const logger = new Logger({
app: 'my-app',
});
logger.set({
app: 'new-app',
});
logger.set('maxLength', 1000);
Add transport for logger
-
type
Transport type or uri for transport -
opts
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 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');
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 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');
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');
MIT