debug-callback
Advanced tools
Comparing version 0.0.3 to 0.0.4
21
index.js
'use strict'; | ||
var _ = require('lodash'); | ||
var stringify = require('json-stringify-safe'); | ||
var canCoerce = function (arg) { | ||
return _.isNumber(arg) || _.isString(arg) || _.isBoolean(arg) || _.isDate(arg) || _.isNull(arg) || _.isUndefined(arg); | ||
}; | ||
var format = function (arg) { | ||
if (canCoerce(arg)) { | ||
return arg; | ||
} else if (arg instanceof Buffer) { | ||
var tostring = arg.toString(); | ||
return tostring.substr(0, 100).replace(/\n/g, '\n\t') + (tostring.length > 100 ? '\n\t...\n\n' : ''); | ||
} else { | ||
var stringified = stringify(arg, null, 4); | ||
return stringified.substr(0, 100).replace(/\n/g, '\n\t') + (stringified.length > 100 ? '\n\t...\n\n' : ''); | ||
} | ||
}; | ||
module.exports = function (name) { | ||
@@ -58,7 +41,7 @@ var debug = require('debug')(name); | ||
var duration = (Date.now() - callbackTimes[key].time) / 1000; | ||
debug('success (%s): ' + msg + '\t\t' + duration + ' seconds\n', format(res)); | ||
debug('success (%o): %s\t\t%d seconds\n', res, msg, duration); | ||
}; | ||
var fail = function (err) { | ||
var duration = (Date.now() - callbackTimes[key].time) / 1000; | ||
debug('failure (%s): ' + msg + '\t\t' + duration.toString() + ' seconds\n', format(err)); | ||
debug('failure (%o): %s\t\t%d seconds\n', err, msg, duration); | ||
}; | ||
@@ -65,0 +48,0 @@ var fin = function () { |
{ | ||
"name": "debug-callback", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "Debug output outstanding callbacks, results, errors, and call times.", | ||
@@ -5,0 +5,0 @@ "repository": { |
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
3623
55