@sec-block/secjs-logger
A simple logging library for SEC-Block System
Last updated 2 years ago by zuweihan1992 .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @sec-block/secjs-logger 
SYNC missed versions from official npm registry.


SEC Logger

JavaScript Style Guide

https://github.com/SEC-Block/secjs-logger

SUMMARY

A simple logging library for SEC-Block

USAGE

A logger has 5 different levels of logging in a specific order:

'fatal', 'error', 'warn', 'info', 'debug' Each of these log levels has its own method on the logging instance. You can set the maximum log level on a logger at runtime.

By default, a logger writes to STDOUT, but given a writeable file path, it will log directly to a file.

Instantiation:

// standardjs style
const logger = require('./logger').createLogger() // logs to STDOUT
const logger = require('./logger').createLogger('development.log') // logs to a file

Logging:

Any of the logging methods take n arguments, which are each joined by ' '. If an argument is not a string, it is string-ified by util.inspect()

logger.info('loading an array', [1,2,3], 'now!')
// info [Sat Jun 12 2018 01:12:05 GMT-0400 (EDT)]  loading an array [ 1, 2, 3, [length]: 3 ] now!
logger.debug('this wont be logged')
// false
logger.setLevel('debug')
logger.debug('this will be logged now')
// debug [Sat Jun 12 2018 01:12:54 GMT-0400 (EDT)]  this will be logged now

Customization:

You can completely customize the look of the log by overriding the format() method on a logger.

logger.format = function(level, date, message) {
  return date.getTime().toString() + '; ' + message
};
logger.debug('message')
// 1276365362167;  message

LICENSE

MIT, see the source.

Current Tags

  • 1.0.3                                ...           latest (2 years ago)

3 Versions

  • 1.0.3                                ...           2 years ago
  • 1.0.2                                ...           2 years ago
  • 1.0.1                                ...           2 years ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (0)
None
Dev Dependencies (0)
None
Dependents (1)

Copyright 2014 - 2016 © taobao.org |