@percy/logger
Advanced tools
Comparing version 1.0.0-beta.8 to 1.0.0-beta.9
26
index.js
@@ -32,3 +32,3 @@ const os = require('os'); | ||
new transports.Console({ | ||
level: 'error', | ||
level: process.env.PERCY_LOGLEVEL || 'info', | ||
stderrLevels: ['error'], | ||
@@ -70,14 +70,16 @@ format: format.combine( | ||
// Patch the error method to handle error objects. Winston accepts objects with | ||
// messages and meta as an argument but will fail to log real error instances. | ||
logger.error = function(message) { | ||
// libraries may also throw errors which are not technically Error instances | ||
if (typeof message === 'object') { | ||
// get the stack trace for debug (no ternary to always fallback to string) | ||
message = (this.loglevel() === 'debug' && message.stack) || message.toString(); | ||
} | ||
// Patch the error and debug methods to handle error objects. Winston accepts objects | ||
// with messages and meta as an argument but will fail to log real error instances. | ||
for (let method of ['error', 'debug']) { | ||
logger[method] = function(message) { | ||
// libraries may also throw errors which are not technically Error instances | ||
if (typeof message === 'object') { | ||
// get the stack trace for debug (no ternary to always fallback to string) | ||
message = (this.loglevel() === 'debug' && message.stack) || message.toString(); | ||
} | ||
// return super.error(message) | ||
return this.constructor.prototype.error.call(this, message); | ||
}; | ||
// return super[method](message) | ||
return this.constructor.prototype[method].call(this, message); | ||
}; | ||
} | ||
@@ -84,0 +86,0 @@ // Patch the query method to return a promise, query the file transport only, |
{ | ||
"name": "@percy/logger", | ||
"version": "1.0.0-beta.8", | ||
"version": "1.0.0-beta.9", | ||
"license": "MIT", | ||
@@ -24,3 +24,3 @@ "main": "index.js", | ||
}, | ||
"gitHead": "6015850e7c20c130d625fcb327b10d7513b35707" | ||
"gitHead": "57a2eeb90c7f5cdf8827c78be1e5c12df581f4b5" | ||
} |
@@ -101,2 +101,10 @@ import fs from 'fs'; | ||
describe('#debug()', () => { | ||
it('is patched to log error instance strings', () => { | ||
let err = { toString: () => 'error' }; | ||
stdio.capture(() => log.debug(err)); | ||
expect(stdio[1]).toEqual(['[percy] error\n']); | ||
}); | ||
}); | ||
describe('#query()', () => { | ||
@@ -103,0 +111,0 @@ beforeEach(() => { |
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
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
11835
248
3