Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@thecolvinco/nodejs-logger

Package Overview
Dependencies
Maintainers
2
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@thecolvinco/nodejs-logger

Nodejs/Express colvin logs standard

  • 0.6.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
14
increased by55.56%
Maintainers
2
Weekly downloads
 
Created
Source

Colvin nodejs logger

A logger abstraction to log message with standard structure and with some useful middlewares

Logger usage

import { Logger } from '@thecolvinco/nodejs-logger';

const logger = new Logger({
  appName: 'My foo app',
  appVersion: '1',
  enviroment: 'production',
  isProduction: true,
  loggerOptions: {}, // Optional for override pourpose
});

logger.info('A simple message')
logger.info('Some fancy message with tags', { tags: ['super-drama', 'fancy-error'] })
logger.info('Some fancy message with tags and extra object data', { tags: ['super-drama', 'fancy-error'], meta: { foo: 'bar' } })

Development output

{
  tags: [ 'super-drama', 'fancy-error' ],
  meta: { foo: 'bar' },
  level: 'info',
  message: 'Some fancy message with tags and extra object data'
}

Production output

{"version":"1","appName":"My foo app","enviroment":"production","tags":["super-drama","fancy-error"],"meta":{"foo":"bar"},"level":"info","message":"Some fancy message with tags and extra object data"}

Middleware usages

import { Logger, expressErrorMiddleware, expressWinstonRequestMiddleware } from '@thecolvinco/nodejs-logger';

const server = express();
const logger = new Logger(
  {
    appName: 'foo',
    appVersion: '1',
    enviroment: 'production',
    isProduction: true,
  }
);

// Log non controlled errors
server.use(expressErrorMiddleware(logger));

// Log all express requests with winston
server.use(expressWinstonRequestMiddleware(logger);

// Log all express requests with winston adding some winston options
server.use(expressWinstonRequestMiddleware(logger, {
  headerBlacklist: ['cookie'],
  dynamicMeta: (req) => ({
    countryCode: req?.cookies?.hc,
    locale: req?.cookies?.hl,
  })},
));

About

This package is maintained by TheColvinCo

LICENSE

Code is licensed under the MIT License.

Keywords

FAQs

Package last updated on 05 Sep 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc