Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Commit

Permalink
馃敟 Remove time and user agent from express messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal Vlas谩k committed Jan 23, 2020
1 parent a0377ec commit d05caa4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/express.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ const expressOnFinished = (logger: Cosmas, req: AckeeRequest) => (_err: Error |
}
const error = res[errorSymbol];
const userAgent = req.headers['user-agent'];
const reqOut = `${res.statusCode} ${req.method} ${req.originalUrl} ${res.time} ms ${userAgent ? userAgent : ''}`;
const reqOut = `${res.statusCode} ${req.method} ${req.originalUrl}`;
const standardOutput = {
data: {
req,
res,
userAgent,
ackId: req.ackId,
},
message: `${reqOut} - Standard output`,
Expand All @@ -55,8 +56,7 @@ const expressMiddleware: RequestHandler = function(
response: AckeeResponse,
next: any
) {
const userAgent = req.headers['user-agent'];
const reqIn = `--- ${req.method} ${req.originalUrl} ${userAgent ? userAgent : ''}`;
const reqIn = `--- ${req.method} ${req.originalUrl}`;
if (!shouldSkipLogging(this, req)) {
this.debug({ req, ackId: req.ackId }, `${reqIn} - Request accepted`);
}
Expand Down
4 changes: 2 additions & 2 deletions src/tests/express.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,15 @@ test('route can be ignored using regexp helper', () => {
});
});

test('user-agent is logged', () => {
test('user-agent is not logged', () => {
const loggerWrites = jest.fn();
const logger = loggerFactory({
streams: [
{
stream: new Writable({
write: (chunk, encoding, next) => {
const json = JSON.parse(chunk);
expect(json.message).toMatch('dummy agent');
expect(json.message).not.toMatch('dummy agent');
loggerWrites();
next();
},
Expand Down

0 comments on commit d05caa4

Please sign in to comment.