Socket
Book a DemoInstallSign in
Socket

diva-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

diva-logger

Modern, fast, lightweight and generic pino-based logger

latest
Source
npmnpm
Version
0.2.2
Version published
Maintainers
1
Created
Source

Modern, fast and lightweight Logger

Modern, fast, lightweight and generic logger. It's based on pino (https://www.npmjs.com/package/pino).

How to Install

npm install diva-logger

Getting Started - Usage

Use it either as

import { Logger } from 'diva-logger'

Logger.trace('hello world')

or

const Logger = require('diva-logger')

Logger.trace('hello world')

API

diva-logger is static. It can be used without instantiation, like

import { Logger } from 'diva-logger' 

try  {
    throw new Error('A recoverable error')
} catch (error) {
    Logger.warn(error)
    // go on
}   

diva-logger also attaches itself gently to the two global events uncaughtException and unhandledRejection. Hence an unhandled exception or an unhandled rejected promise will be properly logged (fatal):

import { Logger } from 'diva-logger' 

throw new Error('This is fatal')

After an unhandled exception or unhandled rejected promise, the process will be terminated with the exit code 1 (after the remaining event stack has been processed).

Chaining

diva-logger supports chaining, like

Logger.trace('trace message').debug('debug message')

Logging Examples, Usage of API

trace(any[, options])

Logger.trace('some trace message')
Logger.trace(process.env)

debug(any[, options])

Logger.debug(12345)

info(any[, options])

Logger.info('info goes here')

warn(any[, options])

Logger.warn('warning - recoverable error')

error(any[, options])

Logger.error('some serious error')
Logger.error(SomeObject)

fatal(any[, options])

Logger.fatal('One of the last messages of the process...')

How to Run Unit Tests

npm run test

Coverage reports are stored within ./coverage. Use any browser and open ./coverage/index.html.

How to Lint (eslint)

npm run lint

Keywords

log

FAQs

Package last updated on 22 Oct 2019

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.