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

molindo-node-logger

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

molindo-node-logger

todo

  • 0.0.1-0
  • prerelease
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
73
decreased by-9.88%
Maintainers
1
Weekly downloads
 
Created
Source

molindo-node-logger

A node.js logger that can be used instead of console.log and friends.

Features

  • Pretty prints messages in development mode.
  • Prints JSON messages in production mode.
  • Errors are printed to stderr, while all other levels are printed to stdout.
  • In development only warnings and errors are printed, while in production all levels are printed.
  • If the process encounters an error, it will log it to the console before shutting down. unhandledRejection errors thrown from promises are logged as well.
  • Offers an express integration that logs HTTP requests, including the operationName in the case of GraphQL requests.
  • Uses the levels and level values from logback: ERROR (40000), WARN (30000), INFO (20000), DEBUG (10000), TRACE (5000).

Usage

import Logger from 'molindo-node-logger';

const logger = new Logger({service: 'pizza-shop'});
logger.trace('Making a salami pizza.');
logger.debug('Adding salami.');
logger.info('Putting it in the oven.');
logger.warn('Don\'t forget to get it out in time …');
logger.error('Oh no, the pizza is burned!');

In production the printed JSON will look like this, except that it's not pretty printed:

{
  "service": "pizza-shop",
  "@timestamp": "2017-10-19T08:26:13.168Z",
  "level": "INFO",
  "level_value": 20000,
  "message": "Pizza is ready!"
}

Express integration

If you're running an express server, you can register the logger middleware to log HTTP requests.

import express from 'express';
import Logger, {createLoggerMiddleware} from 'molindo-node-logger';

const app = express();

const logger = new Logger({service: 'pizza-shop'});
app.use(createLoggerMiddleware({logger}));

Keywords

FAQs

Package last updated on 19 Oct 2017

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