Socket
Book a DemoInstallSign in
Socket

@vizir/simple-json-logger

Package Overview
Dependencies
Maintainers
2
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vizir/simple-json-logger

The simplest json logger. Include typescript definitions.

4.0.0
latest
Source
npmnpm
Version published
Weekly downloads
41
17.14%
Maintainers
2
Weekly downloads
 
Created
Source

@vizir/simple-json-logger

A fast, simple and opinionated json logger to stdout.

npm version Node.js CI

Motivation

This library is designed to be an easy and fast way to log json messages to stdout.

If you want a more advanced solution, we recommend to you use winston.

Installation

$ npm install @vizir/simple-json-logger

Usage

NodeJS Sample with Javascript

const { Logger } = require("@vizir/simple-json-logger");

const logger = new Logger({
  app: "ConsoleApplication",
  requestId: "3a7d3223-e96f-47da-b3bb-73f609b9f55d",
});
logger.debug("debug message", { extraInfo: 123 });
logger.info("info message", { extraInfo: "abc" });
logger.warn("warn message", { moreInfo: "abc123" });
logger.error("error message", { otherInfo: "qwerty" });

Security Filtering

By default, the logger will filter some sensitive values from logs output. They will verify if an object key, contain some of the following words: (The validation is case insensitive)

  • Authorization
  • Password
  • Secret
  • Token
  • Key

You can add or remove the default blacklist, using the includeBlackList or excludeBlackList attribute into options, as following:

const logger = new Logger(
  {
    app: "ConsoleApplication",
    requestId: "3a7d3223-e96f-47da-b3bb-73f609b9f55d",
  },
  {
    includeBlackList: ["myPasswordField"],
    excludeBlackList: ["accessToken"],
  }
);
logger.error("error message", { myPasswordField: "qwerty" });

The output of the following command are:

{
  "app": "ConsoleApplication",
  "requestId": "3a7d3223-e96f-47da-b3bb-73f609b9f55d",
  "level": "error",
  "datetime": "2020-05-20T00:20:10.432Z",
  "message": "origin: error message",
  "myPasswordField": "*sensitive*"
}

Support

Tested in Node.js 10-12.

License

The MIT License (MIT)

Keywords

simple json logger

FAQs

Package last updated on 17 Sep 2021

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.