Skip to content
Browse files

Make build

  • Loading branch information...
1 parent 599f171 commit 6db10d32aa362ac85c3284839d4e1e8313e148e3 @mixu committed Aug 6, 2012
Showing with 19 additions and 12 deletions.
  1. +18 −11 dist/minilog.js
  2. +1 −1 test/example/themes_example.js
View
29 dist/minilog.js
@@ -131,8 +131,7 @@ log.removeListener = log.removeAllListeners = function(ev, callback) {
}
};
-function serialize(args) {
- var items = Array.prototype.slice.call(args);
+log.serialize = function(items) {
if(!JSON || !JSON.stringify) return items;
for(var i = 0; i < items.length; i++) {
if(items[i] && typeof items[i] == 'object') {
@@ -148,11 +147,11 @@ function serialize(args) {
}
exports = module.exports = function create(name) {
- var o = function() { log.emit('item', name, undefined, serialize(arguments)); return o; };
- o.debug = function() { log.emit('item', name, 'debug', serialize(arguments)); return o; };
- o.info = function() { log.emit('item', name, 'info', serialize(arguments)); return o; };
- o.warn = function() { log.emit('item', name, 'warn', serialize(arguments)); return o; };
- o.error = function() { log.emit('item', name, 'error', serialize(arguments)); return o; };
+ var o = function() { log.emit('item', name, undefined, Array.prototype.slice.call(arguments)); return o; };
+ o.debug = function() { log.emit('item', name, 'debug', Array.prototype.slice.call(arguments)); return o; };
+ o.info = function() { log.emit('item', name, 'info', Array.prototype.slice.call(arguments)); return o; };
+ o.warn = function() { log.emit('item', name, 'warn', Array.prototype.slice.call(arguments)); return o; };
+ o.error = function() { log.emit('item', name, 'error', Array.prototype.slice.call(arguments)); return o; };
return o;
};
@@ -162,10 +161,18 @@ exports.format = function(formatter) {
exports.pipe = function(dest) {
var config = {};
- log.on('item', function(name, level, args) {
- if(config.filter && !config.filter(name, level)) return;
- dest.write((config.format ? config : def).format(name, level, args));
- }).on('end', function() { !dest._isStdio && dest.end(); });
+ if(dest._isFormatted) {
+ log.on('item', function(name, level, args) {
+ if(config.filter && !config.filter(name, level)) return;
+ dest.format(name, level, args);
+ });
+ } else {
+ log.on('item', function(name, level, args) {
+ if(config.filter && !config.filter(name, level)) return;
+ dest.write((config.format ? config : def).format(name, level, log.serialize(args)));
+ });
+ }
+ log.on('end', function() { !dest._isStdio && dest.end(); });
var chain = {
filter: function(cb) { config.filter = cb; return chain; },
format: function(cb) { config.format = cb; return chain; },
View
2 test/example/themes_example.js
@@ -1,5 +1,5 @@
var log = require('../../minilog')('app'),
- ConsoleBackend = require('../../backends/node_console');
+ ConsoleBackend = require('../../lib/node/console');
function out() {
log

0 comments on commit 6db10d3

Please sign in to comment.
Something went wrong with that request. Please try again.