winston-postgresql

1.2.0 • Public • Published

winston-postgresql

A Winston transport for PostgreSQL.

Installation

npm install winston-postgresql

Usage

Example usage:

var winston = require("winston");
require("winston-postgresql").PostgreSQL;
 
var logger = new (winston.Logger)();
 
logger.add("PostgreSQL", {
    // Required: A connection string or connection object, passed through to `pg.js` module
    "connString": "user:pw@localhost:5432/db",
 
    // Required: Specify either `customSQL` or a `tableName`
    //
    // `customSQL`: A custom SQL statement that takes 3 parameters:
    // $1: level
    // $2: message
    // $3: metadata
    "customSQL": "select custom_logging_function($1, $2, $3)",
    
    // `tableName`: the name of a table with the following columns: level, message, metadata
    // - See the winston_logs.sql script for an example table definition.
    // - Specifying `tableName` will override `customSQL`.
    "tableName": "winston_logs",
 
    // Optional: A logging level, defaults to "info"
    "level": "error"
});

LICENSE

© Jeffrey Yang, MIT

Package Sidebar

Install

npm i winston-postgresql

Weekly Downloads

40

Version

1.2.0

License

none

Last publish

Collaborators

  • meatballyang