newsource-winston-splunk-logger

3.0.0-beta.15 • Public • Published

Overview

Custom logging module that wraps winston 3.x

Version npm npm Downloads

Installation

 npm install --save newsource-winston-splunk-logger

Setup

import createLogger from "newsource-winston-splunk-logger";

// Minimum required configuration
const config = {
    "appName": string
}

const loggerInstance = createLogger(config);

The LoggerConfig and other main types are located in one of:

dist/cjs/types/types.d.ts
dist/esm/types/types.d.ts

Configuration

Splunk (optional)

const config = {
    appName: 'winston-splunk-logger-application',
    splunk: {
        index: 'winston-index',
        level: 'silly', //optional
        source: 'winston-environment',
        sourcetype: 'winston-splunk-logger',
        token: '123456789',
        url: 'https://splunk.local:8088', 
    }
}

Email (optional)

const config = {
    appName: 'winston-splunk-logger-application',
    email: {
        host: 'smtp.local.com',
        port: 2000,
        from: 'test@local.com',
        to: 'test@local.com',
    }
}

File logging (optional)

const config = {
    appName: 'winston-splunk-logger-application',
    file: {
        dirname: 'logs',
        filename: 'application',
        maxFiles: 10,
        maxSize: 1000000
    },
}      

Cloudwatch logging formatted for mssnews-cloudwatch-log-forwarder

const config = {
    appName: 'winston-splunk-logger-application',
    formatForForwarding: true
}        

Custom log levels (optional)

This is for overriding or adding custom log levels.

const config = {
    appName: 'winston-splunk-logger-application',
    levels:{
        mycustomlevel1: -1,
        mycustomlevel2: -2,
        mycustomlevel3: -3
    }
}

Full example

const config = {
    appName: 'newsource-winston-splunk-logger',
    env: 'dev', // Used in subject like of Email logger
    formatForForwarding: false,
    level: 'silly', // Log level, defaults to silly
    levels:{ // Custom levels (optional)
        mycustomlevel1: -1,
        mycustomlevel2: -2,
        mycustomlevel3: -3
    },
    email: {
        host: 'smtp.local.com',
        port: 2000,
        from: 'test@local.com',
        to: 'test@local.com',
    },
    file: {
        dirname: 'logs', // Directory for log files
        filename: 'application', // Name prefix of log files
        maxFiles: 10, // Max number of files
        maxSize: 1000000 // In bytes
    },
    splunk: {
        index:  'splunk-group',
        source: 'splunk-environment',
        sourcetype: 'application-name',
        token: '123456789-123-123456',
        url: 'https://splunk.example.com:2000',
    }
}

Package Sidebar

Install

npm i newsource-winston-splunk-logger

Weekly Downloads

19

Version

3.0.0-beta.15

License

ISC

Unpacked Size

112 kB

Total Files

18

Last publish

Collaborators

  • mss-npm-user