2.1.7 • Published 4 years ago

winston-couchdb-transport v2.1.7

Weekly downloads
8
License
MIT
Repository
github
Last release
4 years ago

CouchDb NoSQL DB Transport for Winston

The winston-couchdb-transport module allows you to log your winston messages to CouchDB NoSQL DB. Cloned from the Winston-Cloudant-Transport by Håkan Öström.

const winston = require('winston');
const WinstonCouchdb = require('winston-couchdb-transport');

const logger = winston.createLogger({
    transports: [
        new couchdbTransport({
            url: '...',
            db: '...'
        })
    ]
});

Installation

  $ npm install --save winston-couchdb-transport

Usage

Winston-couchdb-transport 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 CouchDB.

Note that the latest version of this transport is made for winston 3.0 and up. If using older version of winston, please use older version (1.x) of this library.

The Cloudant NoSQL DB transport takes the following options:

host        : Access url to db. Including "http://" or "https://"
username    : Username for the CouchDB instance
password    : Password for the CouchDB instance
db          : Name of the databasename to put logs in
logstash    : Write logs in logstash format

host

The host address for a CouchDB DB instance can be retreived from your CouchDB admin interface.

username

The username for a CouchDB DB instance can be retreived from your CouchDB admin interface

password

The password for a CouchDB DB instance can be retreived from your CouchDB admin interface

db

The name of the database where logs should be writen. Default if none priveded is winston-couchdb.

logstash

True or false indicating logs to be writen in logstash format. Default is false.

Result

In your CouchDB instance a new database will be created with the specified name containing a new document for each log. The timestamp will be in the root level of the document and thus aid in sorting. The child node params will vary in formatting depending on the logstash flag but always contain the log itself along with some metadata.

Author

Written by Emil Brolin and Håkan Öström