/logdna-winston

LogDNA's Node.js logging module with support for Winston

Primary LanguageJavaScriptMIT LicenseMIT

Node.js Winston library for logging to LogDNA

Build Status


Install

$ npm install --save logdna-winston

API

Please see the logdna npm module for the API.

Winston Transport

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');

License

MIT © LogDNA

Happy Logging!