New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@nanw/nwlog

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nanw/nwlog

New-wheel logger for NodeJs, just do it

latest
Source
npmnpm
Version
1.0.3
Version published
Maintainers
1
Created
Source

nwlog

A new-wheel logger for NodeJs. Simple do its task

  • Short logging api: as it should be
  • With log written to rotated file
  • Decorate console ondemand, with colors
  • Log file/module name, support custom label. (for cluster mode)
  • NodeJs default console.log/util.format convension
  • Tiny code
const log = require('@nanw/nwlog')(__filename)

//easy api
log('log')

//explicit level
log.debug('log.debug')
log.info('log.info')
log.warn('log.warn')
log.error('log.error')

//formatting
let d = {a: 1, b:'Transylvania'}
log('Formatting: %d %s %j', 12345, 'welcome to', d)
log('test error with stack:', new Error('demo'))

const log2 = require('@nanw/nwlog')('/anotherModule/index.js')
log2('Message from another module')

nwlog screenshot

Options

const nwlog = require('@nanw/nwlog')

nwlog.config({
	//decorateConsole: true,	//whether decorate console.log/console.error. Default: true
	//writeToConsole: true,		//whether write to console for log operations. Default: true
	//fileName: './log/console.log',	//log file. If null, no log file will be created. Default: ./log/console.log
	//maxLength: 4 * 1024 * 1024,		//max file length
	//maxFiles: 3,				//max log files to keep
	//custom: () => 'custom-label-' + process.pid,	//A function to append custom label. E.g. add pid
	//maskPassword: true		//If enabled, tries to identify password string fields in log objects and mask them. Default: false
})

const log = nwlog(__filename)
log('log')

Keywords

logger

FAQs

Package last updated on 15 Oct 2018

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