Skip to content

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

License

Notifications You must be signed in to change notification settings

efugulin/logdna-winston

 
 

Repository files navigation

Node.js Winston library for logging to LogDNA


All Contributors

Install

$ npm install --save logdna-winston

API

Please see @logdna/logger for instantiation options to passthrough to LogDNA's logger client.

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
    indexMeta: 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'
    , indexMeta: true // Optional.  If not provided, it will use the default.
    , data:'Some information' //  Properties besides level, message and indexMeta 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');

// A payload without 'message' will log the stringified object as the message
logger.info({
  key: 'value'
, text: 'This is some text to get logged'
, bool: true
})

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Muaz Siddiqui

💻 📖

Samir Musali

💻 📖

Darin Spivey

💻 📖

Mike Huang

💻 📖

Brian Conn

📖

Mario Casciaro

💻

vilyapilya

🔧

Mike Del Tito

💻 🔧

This project follows the all-contributors specification. Contributions of any kind welcome!

License

Copyright © LogDNA, released under an MIT license. See the LICENSE file and https://opensource.org/licenses/MIT

Happy Logging!

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 96.0%
  • Shell 4.0%