express-winston icon indicating copy to clipboard operation
express-winston copied to clipboard

Log as soon as the request is received

Open ilbonte opened this issue 3 years ago • 0 comments

Just finished setting up express-winston along winston and my logs looks something like this:

1/8/2022, 00:00:34 info:        User 34 is retrieving phone numbers for group 15
1/8/2022, 00:00:34 info:        Requesting phone numbers for group 15
1/8/2022, 00:00:34 info:        Phone numbers for group 15 retrieved
1/8/2022, 00:00:35 info:        GET /api/phone-numbers 200 413ms

What I'd like to have is something like this:

Note that the method and the path are on the first line

1/8/2022, 00:00:34 info:        GET /api/phone-numbers
1/8/2022, 00:00:34 info:        User 34 is retrieving phone numbers for group 15
1/8/2022, 00:00:34 info:        Requesting phone numbers for group 15
1/8/2022, 00:00:34 info:        Phone numbers for group 15 retrieved

Even better like this where request and response are logged as soon as they appens

1/8/2022, 00:00:34 info:        GET /api/phone-numbers
1/8/2022, 00:00:34 info:        User 34 is retrieving phone numbers for group 15
1/8/2022, 00:00:34 info:        Requesting phone numbers for group 15
1/8/2022, 00:00:34 info:        Phone numbers for group 15 retrieved
1/8/2022, 00:00:35 info:        GET /api/phone-numbers 200 413ms

Is it possible to achieve this with express-winston?

ilbonte avatar Jul 31 '22 22:07 ilbonte