Node.js Winston library for logging to LogDNA
$ npm install --save logdna-winston
Please see the logdna npm module for the API.
This module also provides a transport object, which can be added to winston using:
const logdnaWinston = require('logdna-winston');
const winston = require('winston');
const logger = winston.createLogger({});
const options = {
key: apikey,
hostname: myHostname,
ip: ipAddress,
mac: macAddress,
app: appName,
env: envName,
level: level, // Default to debug, maximum level of log, doc: https://github.com/winstonjs/winston#logging-levels
index_meta: true // Defaults to false, when true ensures meta object will be searchable
};
// Only add this line in order to track exceptions
options.handleExceptions = true;
logger.add(new logdnaWinston(options));
// log with meta
logger.log({
level: 'info'
, message: 'Log from LogDNA-winston'
, index_meta: true // Ignore this if you would like to use default setting
, data:'Some information' // Properties besides level, message and index_meta are considered as "meta"
, error: new Error("It's a trap.") // Transport will parse the error object under property 'error'
});
// log without meta
logger.info('Info: Log from LogDNA-winston');
MIT © LogDNA
Happy Logging!