New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

apolitical-logger

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apolitical-logger

Node.js module to expose Apolitical's logger service

latest
npmnpm
Version
0.0.5
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Apolitical Logger

Node.js module to expose Apolitical's logger service

Installation

Install with yarn:

yarn add apolitical-logger

Usage

First of all, include apolitical-logger module:

const apoliticalLogger = require('apolitical-logger');

The recommended way to use apolitical-logger is to create your own logger with the appropriate parameters:

const opts = { logLevel: 'info' };
const logger = apoliticalLogger(opts);

logger.info('Hello World!');

The where function

When debugging, it might be useful to also use the where function to track the location of your logs.

It accepts filename and method parameters, and it creates a child logger:

const opts = { logLevel: 'debug' };
const logger = apoliticalLogger(opts);

const childLogger = logger.where(__filename, 'debugging');
childLogger.debug('Accessed:', { count: 0 });

The metadata object

And also, the metadata object allows you to keep extra info along the logger journey:

const opts = {
  metadata: {
    serviceName: 'apolitical-service'
  }
};
const logger = apoliticalLogger(opts);
logger.info('Service Name');

Logging levels

The supported logging levels are:

{
  error: 0,
  warn: 1,
  info: 2,
  debug: 3
}

Keywords

Backend

FAQs

Package last updated on 02 Sep 2020

Related posts