debug-logger
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -5,4 +5,5 @@ 'use strict'; | ||
var vmDebug = require('debug'); | ||
exports = module.exports = logger; | ||
exports = module.exports = debugLogger; | ||
var DEBUG_NAMESPACE = ':debug'; | ||
var RED = '\x1b[31m'; | ||
@@ -47,3 +48,3 @@ var GREEN = '\x1b[32m'; | ||
if (e.stack) { | ||
errorStrings[1] = '\n stack trace: ' + e.stack; | ||
errorStrings[1] = 'Stack trace:\n' + e.stack; | ||
} | ||
@@ -55,24 +56,20 @@ return errorStrings; | ||
} | ||
errorStrings[1] = '\n object: ' + util.inspect(e); | ||
errorStrings[1] = 'Inspected object:\n' + util.inspect(e); | ||
return errorStrings; | ||
}; | ||
function getFormattedMessage(message, e) { | ||
var errorStrings = getErrorMessage(e); | ||
return message + errorStrings[0] + errorStrings[1]; | ||
function getPadding(size){ | ||
return new Array(size).join(' '); | ||
} | ||
function logger(namespace) { | ||
function debugLogger(namespace) { | ||
var log = vmDebug(namespace); | ||
var debug = vmDebug(namespace + ':debug'); | ||
var debug = vmDebug(namespace + DEBUG_NAMESPACE); | ||
var defaultPadding = '\n' + getPadding(namespace.length + DEBUG_NAMESPACE.length + 11); | ||
var loggerObj = { | ||
var logger = { | ||
logger : log, | ||
debugLogger : debug, | ||
isEnabled : function() { | ||
return log.enabled; | ||
}, | ||
isDebugEnabled : function() { | ||
return debug.enabled; | ||
} | ||
isEnabled : log.enabled, | ||
isDebugEnabled : debug.enabled | ||
}; | ||
@@ -86,8 +83,10 @@ | ||
loggerObj[level] = function(message, e) { | ||
levelLog(color + levels[level].prefix + reset + getFormattedMessage(message, e)); | ||
logger[level] = function(message, e) { | ||
var errorStrings = getErrorMessage(e); | ||
var padding = errorStrings[1] != '' ? defaultPadding : ''; | ||
levelLog(color + levels[level].prefix + reset + message + errorStrings[0] + padding + errorStrings[1]); | ||
}; | ||
}); | ||
return loggerObj; | ||
return logger; | ||
}; |
{ | ||
"name": "debug-logger", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "A wrapper for visionmedia's debug logger", | ||
@@ -5,0 +5,0 @@ "main": "debug-logger.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3744
6
94