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

@bonniernews/exp-logger

Package Overview
Dependencies
Maintainers
0
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bonniernews/exp-logger

Simple bootstrapping of pino logger

  • 4.1.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
469
increased by7.82%
Maintainers
0
Weekly downloads
 
Created
Source

exp-logger

Simple logger package to unify how logging is done with (configurable) remapping

NPM


defaults

  • trace -> DEBUG
  • debug -> DEBUG
  • info -> INFO
  • warn -> WARNING
  • error -> ERROR
  • fatal -> CRITICAL

options

  logLevel // defaults to info
  mixin  // pino mixins, passed down to pino as is
  formatLog  // pino formatter.log function, passed down to pino as is

example


const logger = require('@bonniernews/exp-logger')()

logger.info("Hello world")

/* 
-- expected output
[15:19:13.240] INFO: Hello world
*/

Format the log object

To change the shape of the log object to match gcp error-reporting structure or similiar, use formatLog

const expLogger = require('@bonniernews/exp-logger');

const logger = expLogger({
    formatLog: (obj) => {
        if (!obj.err) {
           return obj;
        }
        const stackTrace = obj.err?.stack;
        return {
            ...obj,
            ...(stackTrace && { stack_trace: stackTrace }),
        };
    }
);

logger.error(new Error('Something wrong'));

FAQs

Package last updated on 04 Nov 2024

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