0.0.7 • Published 8 months ago

alien-node-winston-utils v0.0.7

Weekly downloads
120
License
MIT
Repository
github
Last release
8 months ago

alien-node-winston-utils

Helper functions for Winston logging on NodeJS. The functions are pure and curried with Ramda.

Build Status Coverage Status npm version Dependency Status

Install

$ npm install alien-node-winston-utils --save

Run the specs

$ npm test

Usage

// Example config file in Node
var loggerUtils = require('alien-node-winston-utils');

// ...

  logging : {
    winston : {
      transports : [
        {
          name          : 'console',
          level         : 'debug',
          timestamp     : loggerUtils.getDateString,
          colorize      : true,
          transportType : 'console'
        },
        {
          name             : 'file',
          level            : 'error',
          timestamp        : loggerUtils.getDateString,
          colorize         : true,
          transportType    : 'file',
          filename         : 'logs/activity.log',
          json             : false, // required for formatter to work
          formatter        : loggerUtils.getFormatter,
          handleExceptions : true,
          datePattern      : '.yyyy-MM-dd' // dictates how logs are rotated - more specific pattern rotates more often
        }
      ],
      strategies : {
        console : winston.transports.Console,
        file    : winston.transports.DailyRotateFile
      }
    }
  },
  
// ...

Methods

getDateString

This is just a helper for Winston's timestamp option, which just returns new Date().toString()

getFormatter

This is the primary use of this library. As seen in the usage above, use it as a pointer reference. As seen in the TODO below, we will want to make this a true getter which accepts a template param. But for now, it works just fine.

TODO

  • Currently there is only one formatter. Allowing it to accept a decorator would be considerate.
0.0.7

8 months ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

7 years ago

0.0.3

8 years ago

0.0.2

9 years ago

0.0.1

9 years ago