Coder Social home page Coder Social logo

logdna-winston's Introduction

Node.js Winston library for logging to LogDNA


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
})

License

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

Happy Logging!

logdna-winston's People

Contributors

smusali avatar darinspivey avatar logdnabot avatar respectus avatar lyhuang avatar theconnman avatar mariocasciaro avatar mdeltito avatar vilyapilya avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.