0
Fork 0
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:
Juan Picado 2020-12-13 22:58:36 +01:00 committed by GitHub
parent 2ea17ced2c
commit 39376be345
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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();