mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-12-30 22:34:10 -05:00
logging caused failure in case of errors
This commit is contained in:
parent
9ee525b317
commit
3596a12eb7
1 changed files with 21 additions and 15 deletions
|
@ -58,7 +58,9 @@ Storage.prototype.request = function(options, cb) {
|
|||
body: json,
|
||||
ca: this.ca,
|
||||
}, function(err, res, body) {
|
||||
if (!err) {
|
||||
var res_length = body.length;
|
||||
|
||||
if (options.json) {
|
||||
try {
|
||||
body = JSON.parse(body);
|
||||
|
@ -67,26 +69,30 @@ Storage.prototype.request = function(options, cb) {
|
|||
}
|
||||
}
|
||||
|
||||
if (typeof(body) === 'object' && body != null) {
|
||||
if (typeof(body) === 'object' && body !== null) {
|
||||
if (body.error) {
|
||||
var error = body.error;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var error = err.message;
|
||||
}
|
||||
|
||||
var msg = '@{status}, req: \'@{request.method} @{request.url}\'';
|
||||
var msg = '@{!status}, req: \'@{request.method} @{request.url}\'';
|
||||
if (error) {
|
||||
msg += ', error: @{!error}';
|
||||
} else {
|
||||
msg += ', bytes: @{bytes.in}/@{bytes.out}';
|
||||
}
|
||||
self.logger.warn({
|
||||
err: err,
|
||||
request: {method: method, url: uri},
|
||||
level: 35, // http
|
||||
status: res.statusCode,
|
||||
status: res != null ? res.statusCode : 'ERR',
|
||||
error: error,
|
||||
bytes: {
|
||||
in: json ? json.length : 0,
|
||||
out: res_length,
|
||||
out: res_length || 0,
|
||||
}
|
||||
}, msg);
|
||||
if (cb) cb.apply(self, arguments);
|
||||
|
|
Loading…
Reference in a new issue