Giter VIP home page Giter VIP logo

winston-postgres's Introduction

Postgres Transport for Winston

The winston-postgres module allows you to log your winston messages to a postgresql db.

var Postgres = require('winston-postgres').Postgres;

winston.add(winston.transports.Postgres, {
  ssl: false, // are you sure you want to do this?
  timestamp: true,
  connectionString: 'postgres://admin:admin@localhost:5432/api',
  tableName: 'winston-logs',
  ignoreMessage: function(level, message, metadata) {
    if (message === 'something to ignore') {
      return true;
    }
    return false;
  }
});

Installation

  $ npm install winston-postgres

Usage

winston-postgres is just like any other transport for winston. When adding it to winston, it takes some options so that it knows where to log to postgres.

The postgres transport takes the following options:

ssl: boolean to decide whether to disable ssl-secured db connection
timestamp: boolean to decide whether to attach timestamp field to metadata (if metadata is null, no timestamp is attached)
connectionString: the db connection uri
databaseFunction: the name of a database function accepting 3 arguments (level, message, metadata)
tableName: the table (with columns 'level', 'message', 'metadata') to which to log
ignoreMessage: (optional) a function of signature (level, message, metadata) -> boolean which can be used to determine whether to ignore a log message

One of 'tableName' and 'databaseFunction' must be present.

winston-postgres's People

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.