3.0.0-beta.16 • Published 4 months ago

newsource-winston-splunk-logger v3.0.0-beta.16

Weekly downloads
28
License
ISC
Repository
-
Last release
4 months ago

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);

If using v3.x of this logger for an AWS Lambda DO NOT use anything but the Console transport. This logger utilizes Winston v3.x which longer keeps a Lambda function alive long enough to push to Splunk. Use a CloudWatch forwarder to get that content into Splunk.

The LoggerConfig and other 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',
    }
}
3.0.0-beta.16

4 months ago

3.0.0-beta.1

2 years ago

3.0.0-beta.3

2 years ago

3.0.0-beta.2

2 years ago

3.0.0-beta.4

2 years ago

3.0.0-beta.7

2 years ago

3.0.0-beta.6

2 years ago

3.0.0-beta.9

2 years ago

3.0.0-beta.8

2 years ago

3.0.0-beta.10

2 years ago

3.0.0-beta.11

2 years ago

3.0.0-beta.12

2 years ago

3.0.0-beta.13

2 years ago

3.0.0-beta.14

2 years ago

3.0.0-beta.15

2 years ago

2.1.4

3 years ago

2.1.3

3 years ago

2.1.2

4 years ago

2.1.1

4 years ago

2.1.0

6 years ago

2.0.0

6 years ago

1.0.20

6 years ago

1.0.19

6 years ago

1.0.18

6 years ago

1.0.17

7 years ago

1.0.16

8 years ago

1.0.15

8 years ago

1.0.14

8 years ago

1.0.13

8 years ago

1.0.12

8 years ago

1.0.11

8 years ago

1.0.10

8 years ago

1.0.9

8 years ago

1.0.8

8 years ago

1.0.7

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago