coralogix-logger-bunyan
TypeScript icon, indicating that this package has built-in type declarations

1.0.10 • Public • Published

npm version

Description

Use coralogix-logger-bunyan to easily add a stream to bunyan in order to send your logs to Coralogix's log analytics platform.

Installation

npm install --save coralogix-logger-bunyan

Javascript example (see ts example below)

var bunyan = require("bunyan");
var CoralogixBunyan = require("coralogix-logger-bunyan");
 
// global configuration for coralogix
var config = {
    privateKey: "YOUR PRIVATE KEY",
    applicationName: "YOUR APP NAME",
    subsystemName: "YOUR SUBSYSTEM",
};
 
CoralogixBunyan.CoralogixStream.configure(config);
 
// configure bunyan to user coralogix stram
var logger = bunyan.createLogger({
    name: 'BUNYAN_ROOT',
    streams: [
        {
            level: 'info',
            stream: new CoralogixBunyan.CoralogixStream({category:"YOUR CATEGORY"}),
            type: 'raw'
        }
    ]
});
 
// use bunyan
logger.info('hello bunyan');
// use bunyan child loggers and assign category to them
var childLogger = logger.child({category:"CHILD CATEGORY"});
childLogger.error("Child logger bunyan"); 

Typescript example

import * as bunyan from "bunyan";
import {CoralogixStream} from "coralogix-logger-stram";
 
const config = {
    privateKey: "YOUR KEY",
    applicationName: "YOUR APPLICATION NAME",
    subsystemName: "YOUR SUBSYSTEM"
}
 
CoralogixStream.configure(config);
 
var logger = bunyan.createLogger({
    name: 'BUNYAN_ROOT',
    streams: [
        {
            level: 'info',
            stream: new CoralogixStream({category:"ROOT"}),
            type: 'raw'
        }
    ]
});
 
logger.info('hello world');
 
let childLogger = logger.child({category:"CHILD CATEGORY"});
childLogger.error("hello from child logger");

Readme

Keywords

Package Sidebar

Install

npm i coralogix-logger-bunyan

Weekly Downloads

1,497

Version

1.0.10

License

ISC

Last publish

Collaborators

  • yonifarin