New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

another-logger

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

another-logger

Yet another Node console.log alternative.

  • 1.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
increased by66.67%
Maintainers
1
Weekly downloads
 
Created
Source

another-logger npm

Yet another Node console.log alternative. Inspired by the looks of Yarn.

Installation

# yarn
yarn add another-logger
# npm
npm install another-logger

Usage

const Logger = require('another-logger')
const log = new Logger()

log.debug('test 123 foobar')
log.info('huh, neat')
log.success('woo we did it')
log.warn('that doesnt sound good')
log.error('shitshitshit')

Example screenshot 1

const Logger = require('another-logger')
const log = new Logger('myapp', {
	timestamp: true,
	minLevel: 0,
	levels: {
		custom: {level: 2, text: 'look at me', style: require('chalk').underline.bold.magenta}
	}
})

log.debug('test 123 foobar')
log.info('huh, neat')
log.success('woo we did it')
log.warn('that doesnt sound good')
log.error('shitshitshit')
log.custom('woah dude')

Example screenshot 2

Documentation

Logger.defaultLevels

The default log levels loaded in without any configuration. These will remain if you pass custom levels in to the constructor, unless you override them.

const log = new Logger([[label, ]config])

Create a new logger instance.

config is an object with the following properties:

  • timestamp - True or false. If true, a timestamp is included in front of all output.
  • minLevel - The minimum numeric level to output. Any output from a level less than this will be omitted. Defaults to 1, which includes everything except debug in the default levels.
  • maxLevel - The maximum numeric level to output. Defaults to Infinity, i.e. there is no maximum.
  • levels - An object of additional levels to add to the logger. For example:
  • label - A label to print along with all output. Note that this can also be specified as a first argument in the constructor; if both are specified, the object property takes precedence.
const myLogger = new Logger('global', {
  timestamp: true,
  levels: {
    messedItUp: {level: 2, text: 'problem:'}
  }
})

log.<name>(content...) or log._log(name, content...)

Execute a log. name can be any level name - one of the defaults of debug, info, success, warn, or error, or a custom one provided in the constructor. Content arguments are processed via require('util').format() which means it works in the same way as console.log in regards to format strings, object previewing, etc.

myLogger.messedItUp('some error info') //=> 15:47:13 global problem: some error info

Better documentation coming soon hopefully.

License

MIT

FAQs

Package last updated on 20 May 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

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