Socket
Socket
Sign inDemoInstall

bellman

Package Overview
Dependencies
18
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    bellman

Yet another console logger. A pretty and powerful one, though.


Version published
Weekly downloads
26
increased by550%
Maintainers
1
Install size
5.65 MB
Created
Weekly downloads
 

Readme

Source

Bellman

Yet another console logger. A pretty and powerful one, though.

yarn add bellman

Methods

  • reg - registers the file from which logging methods will be called to adjust the width of the :caller row

Default config

const Logger = require('bellman')

new Logger()
  .reg()
  .info('info message')
  .debug('debug message')
  .warn('warning message')
  .error('error: %s', new Error())

Default config

Custom config

const Logger = require('bellman')

const userConfig = {
  timeTmp: 'HH:mm',
  lineTmp: ':level :time :caller :message',
  colorize: true,
  callerColor: 'yellow.bold',
  levelMap: {
    debug: 'blue',
    info: 'green',
    panic: 'red'
  },
  levelMin: 'debug',
  isFullStack: true
}

new Logger(userConfig)
  .reg()
  .info('info line')
  .debug('debug line')
  .panic('panic line: %s', new Error())

Custom config

Config

  • lineTmp - sets the logging line format. Supported placeholders:
    • :time - a timestamp in the format defined by the timeTmp config option
    • :level - a name of the logging method that has been called
    • :caller - a name of the file and a number of the line from which the logging method has been called
    • :message - a formatted message combined from the arguments passed to the logging method (util.format is used to fromat messages)
  • timeTmp - sets the timestamp format (moment is used to format timestamps)
  • colorize - overrides whether the coloring should be used or not (chalk is used for colorization)
  • callerColor - sets the :caller part color.
  • levelMap - sets the names, priorities, and colors of the logging methods
  • levelMin - sets the logging level
  • isFullStack - sets whether the error stack formatter should be used or not
    • if unset, all the lines that refer files out of the project's directory and all the files within node_modules directories will be removed
    • if set, no modifications will be applied to the error-stacks
    • isFullStack may be overridden with STACK=full and FULLSTACK=true environment variables

Events

  • log - emits metadata of a logged line:
    • time - a formateed timestamp
    • level - a name of the logged message that has been called
    • caller - a name of the file and a number of the line from which the logging method has been called
    • message - a formatted message
    • args - arguments passed the logged message

Keywords

FAQs

Last updated on 20 Oct 2019

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc