question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[middlewares] Add `timestamp` option to logger

See original GitHub issue

Would be great if the logger could have an option to print out the timestamp via timestamp property.

something like

app.use(logger({ timestamp: { format: 'MM:SS' } }))

and then

08:23:12 GET / 200 OK

I’m thinking of this option:

format: string 

Probably could be consumed by some date library and then transformed into a timestamp

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Arnovskycommented, Jul 18, 2020

I would like to take this issue if possible, would adding a dependency (something like day.js) for handling formatting of dates be acceptable?

Shouldn’t time-stamping be a default behavior as-well?

1reaction
KalebMillscommented, Jul 15, 2020

output [unit of time] is somewhat ambiguous. Are these options attempting to achieve time formatting? If so, would it not be better to pass something like format: 'HH:MM:SS', which can be parsed and output as such?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Add a custom timestamp format option on Logger Middleware
I would like to set my own time configuration. it would be like: timestampFormat := "2006-01-02 15:04:05.00000" e.Use(middleware.
Read more >
Adding timestamps to all console messages - node.js
It has a ton more logging options including logging to a json file or database. These always have timestamps by default. Just a...
Read more >
A Guide To Writing Logging Middleware in Go
This is an opinionated guide on how to write extensible logging middleware for Go web services. I've had a number of requests to...
Read more >
Logger - Fiber
Logger middleware for Fiber that logs HTTP request/response details. Table of Contents.
Read more >
How we built a Node.js Middleware to Log HTTP API ... - Moesif
A guide on how we built our Node.js middleware that logs HTTP API Calls. ... Sometimes logging to stdout isn't an option and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found