1.1.3 • Published 7 years ago

spacecraft-logger v1.1.3

Weekly downloads
6
License
MIT
Repository
github
Last release
7 years ago

spacecraft-logger

a smart logger component for any application

Usage

Normal

var logger = require('../')();

no file output

var logger = require('../')({file: false});

Simple Example

var logger = require('../')();

logger.log('hello');
logger.trace('hello', 'world');
logger.debug('hello %s',  'world', 123);
logger.info('hello %s %d',  'world', 123, {foo:'bar'});
logger.warn('hello %s %d %j', 'world', 123, {foo:'bar'});
logger.error('hello %s %d %j', 'world', 123, {foo:'bar'}, [1, 2, 3, 4], Object);

Options

PropertyDefaultDescription
dateformat"yyyy-mm-dd HH:MM:ss.L"date output value in format {{timestamp}}
format"{{timestamp}} <{{title}}> {{message}} (in {{file}}:{{line}})"output format
colortrueoutput color in console
filetrueis output file log in logs/*
silentfalseis output log in console

enable just when property file is true:

PropertyDefaultDescription
root'.'root path
logPathFormat'{{root}}/{{prefix}}.{{date}}.log'output file path format
splitFormat'yyyymmdd'file split format
allLogsFileNamefalseif this is string, output all type of log in one file
maxLogFiles10max log file number

Customize output format

console format tag:

  • timestamp: current time
  • title: method name, default is 'log', 'trace', 'debug', 'info', 'warn', 'error','fatal'
  • level: method level, default is 'log':0, 'trace':1, 'debug':2, 'info':3, 'warn':4, 'error':5, 'fatal':6
  • message: printf message, support %s string, %d number, %j JSON and auto inspect
  • file: file name
  • line: line number
  • pos: position
  • path: file's path
  • method: method name of caller
  • stack: call stack message

License

MIT Licensed. Copyright (c) moonrailgun 2017.

1.1.3

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.0

7 years ago