spacecraft-logger
a smart logger component for any application
Usage
Normal
var logger = ;
no file output
var logger = file: false;
Simple Example
var logger = ; logger;logger;logger;logger;logger;logger;
Options
Property | Default | Description |
---|---|---|
dateformat | "yyyy-mm-dd HH:MM:ss.L" | date output value in format {{timestamp}} |
format | "{{timestamp}} <{{title}}> {{message}} (in {{file}}:{{line}})" | output format |
color | true | output color in console |
file | true | is output file log in logs/* |
silent | false | is output log in console |
enable just when property file is true:
Property | Default | Description |
---|---|---|
root | '.' | root path |
logPathFormat | '{{root}}/{{prefix}}.{{date}}.log' | output file path format |
splitFormat | 'yyyymmdd' | file split format |
allLogsFileName | false | if this is string, output all type of log in one file |
maxLogFiles | 10 | max log file number |
Customize output format
console format tag:
timestamp
: current timetitle
: 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':6message
: printf message, support %s string, %d number, %j JSON and auto inspectfile
: file nameline
: line numberpos
: positionpath
: file's pathmethod
: method name of callerstack
: call stack message
License
MIT Licensed. Copyright (c) moonrailgun 2017.