mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-12-30 22:34:10 -05:00
feat: skip log static content from web (#2027)
The PR #2026 will create more noise because the static content is smaller and segmented, this PR skip all those entries to the log.
This commit is contained in:
parent
2ea17ced2c
commit
39376be345
1 changed files with 27 additions and 21 deletions
|
@ -190,7 +190,10 @@ export function log(config: Config) {
|
|||
}
|
||||
|
||||
req.url = req.originalUrl;
|
||||
req.log.info({ req: req, ip: req.ip }, "@{ip} requested '@{req.method} @{req.url}'");
|
||||
// avoid log noise data from static content
|
||||
if (req.originalUrl.match(/static/) === null) {
|
||||
req.log.info({req: req, ip: req.ip}, "@{ip} requested '@{req.method} @{req.url}'");
|
||||
}
|
||||
req.originalUrl = req.url;
|
||||
|
||||
if (_.isNil(_auth) === false) {
|
||||
|
@ -237,26 +240,29 @@ export function log(config: Config) {
|
|||
}
|
||||
|
||||
req.url = req.originalUrl;
|
||||
req.log.warn(
|
||||
{
|
||||
request: {
|
||||
method: req.method,
|
||||
url: req.url,
|
||||
},
|
||||
level: 35, // http
|
||||
user: (req.remote_user && req.remote_user.name) || null,
|
||||
remoteIP,
|
||||
status: res.statusCode,
|
||||
error: res._verdaccio_error,
|
||||
bytes: {
|
||||
in: bytesin,
|
||||
out: bytesout,
|
||||
},
|
||||
},
|
||||
message
|
||||
);
|
||||
req.originalUrl = req.url;
|
||||
};
|
||||
// avoid log noise data from static content
|
||||
if (req.url.match(/static/) === null) {
|
||||
req.log.warn(
|
||||
{
|
||||
request: {
|
||||
method: req.method,
|
||||
url: req.url,
|
||||
},
|
||||
level: 35, // http
|
||||
user: (req.remote_user && req.remote_user.name) || null,
|
||||
remoteIP,
|
||||
status: res.statusCode,
|
||||
error: res._verdaccio_error,
|
||||
bytes: {
|
||||
in: bytesin,
|
||||
out: bytesout,
|
||||
},
|
||||
},
|
||||
message
|
||||
);
|
||||
req.originalUrl = req.url;
|
||||
}
|
||||
}
|
||||
|
||||
req.on('close', function(): void {
|
||||
log();
|
||||
|
|
Loading…
Reference in a new issue