@kofile/log
Advanced tools
Comparing version 3.0.0 to 4.0.0
41
Log.js
@@ -10,2 +10,23 @@ const util = require('util') | ||
const formatMessageProxy = makeMessage => | ||
new Proxy(makeMessage, { | ||
apply: (target, thisArg, argumentsList) => { | ||
const [message, supplement] = argumentsList | ||
const formattedMessage = target(message) | ||
let finalMessage = formattedMessage | ||
if (supplement) { | ||
finalMessage = `${finalMessage} | ||
Additional info: | ||
${prettyoutput(supplement, { indentationLength: 2, alignKeyValues: false }, 2)} | ||
` | ||
} | ||
return finalMessage | ||
} | ||
}) | ||
const formatErrorProxy = makeMessage => | ||
@@ -136,5 +157,7 @@ new Proxy(makeMessage, { | ||
this._formatError = formatErrorProxy(formatMessageFor(klass.LEVELS.ERROR)) | ||
this._formatWarning = formatMessageFor(klass.LEVELS.WARN) | ||
this._formatInfo = formatMessageFor(klass.LEVELS.INFO) | ||
this._formatDebug = formatMessageFor(klass.LEVELS.DEBUG) | ||
this._formatWarning = formatMessageProxy( | ||
formatMessageFor(klass.LEVELS.WARN) | ||
) | ||
this._formatInfo = formatMessageProxy(formatMessageFor(klass.LEVELS.INFO)) | ||
this._formatDebug = formatMessageProxy(formatMessageFor(klass.LEVELS.DEBUG)) | ||
@@ -172,17 +195,17 @@ this._defaultTimerCallback = params.defaultTimerCallback || (() => {}) | ||
warn (message, ...args) { | ||
warn (message, supplement) { | ||
if (this._shouldLog(1)) { | ||
this._adapter.warn(this._formatWarning(message), ...args) | ||
this._adapter.warn(this._formatWarning(message, supplement)) | ||
} | ||
} | ||
info (message, ...args) { | ||
info (message, supplement) { | ||
if (this._shouldLog(2)) { | ||
this._adapter.info(this._formatInfo(message), ...args) | ||
this._adapter.info(this._formatInfo(message, supplement)) | ||
} | ||
} | ||
debug (message, ...args) { | ||
debug (message, supplement) { | ||
if (this._shouldLog(3)) { | ||
this._adapter.debug(this._formatDebug(message), ...args) | ||
this._adapter.debug(this._formatDebug(message, supplement)) | ||
} | ||
@@ -189,0 +212,0 @@ } |
@@ -1,1 +0,1 @@ | ||
{"name":"@kofile/log","version":"3.0.0","description":"Node log wrapper","author":"Evan Sherwood <evan@sherwood.io>","license":"MIT","main":"index.js","files":["index.js","Log.js","adapters/Console/index.js","adapters/Adapter.js","adapters/index.js"],"devDependencies":{"ava":"^0.22.0","commitizen":"^2.9.6","coveralls":"^2.13.1","cz-cli":"^1.0.0","cz-conventional-changelog":"^2.0.0","husky":"^0.13.4","lint-staged":"^3.6.0","nyc":"^11.1.0","prettier-standard":"^6.0.0","semantic-release":"^8.2.0","sinon":"^4.0.1","snazzy":"^7.0.0","standard":"^10.0.3"},"lint-staged":{"*.js":["prettier-standard","git add"]},"scripts":{"precommit":"lint-staged","commit":"git-cz","lint":"standard | snazzy","test":"nyc ava","semantic-release":"semantic-release pre && npm publish && semantic-release post"},"config":{"commitizen":{"path":"node_modules/cz-conventional-changelog"}},"nyc":{"include":["index.js","Log.js","adapters/Console/index.js","adapters/Adapter.js","adapters/index.js"]},"repository":{"type":"git","url":"https://github.com/kofile/log.git"},"dependencies":{"@kofile/timer":"^1.0.1","chalk":"^2.3.0","prettyoutput":"https://github.com/neezer/prettyoutput"}} | ||
{"name":"@kofile/log","version":"4.0.0","description":"Node log wrapper","author":"Evan Sherwood <evan@sherwood.io>","license":"MIT","main":"index.js","files":["index.js","Log.js","adapters/Console/index.js","adapters/Adapter.js","adapters/index.js"],"devDependencies":{"ava":"^0.22.0","commitizen":"^2.9.6","coveralls":"^2.13.1","cz-cli":"^1.0.0","cz-conventional-changelog":"^2.0.0","husky":"^0.13.4","lint-staged":"^3.6.0","nyc":"^11.1.0","prettier-standard":"^6.0.0","semantic-release":"^8.2.0","sinon":"^4.0.1","snazzy":"^7.0.0","standard":"^10.0.3"},"lint-staged":{"*.js":["prettier-standard","git add"]},"scripts":{"precommit":"lint-staged","commit":"git-cz","lint":"standard | snazzy","test":"nyc ava","semantic-release":"semantic-release pre && npm publish && semantic-release post"},"config":{"commitizen":{"path":"node_modules/cz-conventional-changelog"}},"nyc":{"include":["index.js","Log.js","adapters/Console/index.js","adapters/Adapter.js","adapters/index.js"]},"repository":{"type":"git","url":"https://github.com/kofile/log.git"},"dependencies":{"@kofile/timer":"^1.0.1","chalk":"^2.3.0","prettyoutput":"https://github.com/neezer/prettyoutput"}} |
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
13181
237