better-logs
Advanced tools
Comparing version 2.0.1 to 2.1.1
@@ -19,9 +19,9 @@ var _ = require('lodash'); | ||
this._groups = {}; | ||
this._formats = {}; | ||
this._modes = {}; | ||
this._visible = {}; // Map section => Map type => Boolean | ||
this._outputs = {}; // Map section => Map type => Writable | ||
this._groups = {}; // Map group => array of sections | ||
this._formats = {}; // Map type => format function | ||
this._modes = {}; // Map mode => mode options | ||
this._display = {}; // Display options | ||
this._outputs = {}; // [section|_default][type|_default] | ||
this._visible = {}; // [section|_default][type|_default] | ||
if (typeof opts === 'object') { | ||
@@ -198,3 +198,3 @@ this.config(opts); | ||
var message = ctl._formats[type].apply(extend({ logType: type }, _.pick(log, ['dateformat', 'section', 'stackIndex', 'maxTraceDepth'])), arguments); | ||
var message = ctl._formats[type].apply(extend({ section: log.section, logType: type }, ctl._display, log._display), arguments); | ||
// console.log('writing', message) | ||
@@ -260,2 +260,5 @@ | ||
var self = this; | ||
if (typeof opts.display === 'object') { | ||
extend(self._display, opts.display); | ||
} | ||
if (opts.groups) { | ||
@@ -307,2 +310,7 @@ Object.keys(opts.groups).forEach(function (name) { return self.group(name, opts.groups[name]) }) | ||
Controller.prototype.display = function (key, val) { | ||
if (typeof key !== 'string') return; | ||
this._display[key] = val; | ||
} | ||
Controller.prototype.modes = function () { | ||
@@ -309,0 +317,0 @@ return Object.keys(this._modes); |
22
index.js
@@ -16,8 +16,14 @@ // | ||
controller.config({ | ||
mode: 'normal', | ||
outputs: { | ||
_default: process.stdout | ||
_default: process.stdout, | ||
}, | ||
groups: { | ||
normal: ['info', 'warn', 'error'], | ||
}, | ||
display: { | ||
dateformat: 'yyyy-mm-dd HH:MM:ss', | ||
stackIndex: 1, | ||
maxTraceDepth: 20, | ||
}, | ||
formats: { | ||
@@ -31,10 +37,8 @@ log: "{{timestamp}}".grey + " info".cyan + " [{{section}}] {{message}}".white + " ({{file}}:{{line}})".grey, | ||
modes: { | ||
normal: ['info', 'warn', 'error'], | ||
verbose: ['trace', 'normal', 'debug', 'console'], | ||
test: ['test'], | ||
critical: ['error'], | ||
silent: [], | ||
normal: { show: ['normal'] }, | ||
verbose: { show: ['normal', 'debug', 'console'] }, | ||
test: { showByDefault: false, show: ['test'] }, | ||
critical: { showByDefault: false, show: ['error'] }, | ||
silent: { showByDefault: false }, | ||
}, | ||
output: 'console', | ||
mode: 'normal', | ||
showByDefault: true, | ||
@@ -41,0 +45,0 @@ show: [], |
@@ -10,7 +10,5 @@ var util = require('util'); | ||
this.section = opts.section || 'general'; | ||
this.stackIndex = opts.stackIndex || 1; | ||
this.maxTraceDepth = opts.maxTraceDepth || 20; | ||
this.dateformat = opts.dateformat || 'yyyy-mm-dd HH:MM:ss'; | ||
this.started = false; | ||
this.started = false; | ||
this._display = {}; | ||
this._unwritten = []; | ||
@@ -17,0 +15,0 @@ |
{ | ||
"name": "better-logs", | ||
"version": "2.0.1", | ||
"version": "2.1.1", | ||
"description": "Really flexible and fast logger for web servers, applications and daemons", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -154,3 +154,3 @@ var assert = require('assert'); | ||
var log = BetterLogs('testSectionName'); | ||
log.dateformat = 'HH:MM year: yyyy' | ||
log.config({ display: { dateformat: 'HH:MM year: yyyy' } }) | ||
log.format('testFormatTime', '{{timestamp}}'); | ||
@@ -157,0 +157,0 @@ var logged = ''; |
42515
1017