Skip to content

[custom-plugin-lib] Is it possible to customize the logged date format? #481

Discussion options

You must be logged in to vote

Yep I tried, you can specify this in your index.js

module.exports.options = {
  logger: {
    timestamp: () => `,"time":"${new Date(Date.now()).toISOString()}"`,
  },
}

In this way lc39 will use this function as the Pino configuration object.

This is the output:

{"level":30,"time":"2024-04-29T19:09:11.002Z","pid":71486,"hostname":"NB004C","msg":"Server listening at http://0.0.0.0:3000"}

Maybe your best option is something like:

timestamp: () => `,"time":${Date.now()}, "timeIso":"${new Date(Date.now()).toISOString()}"`,

So you can get both versions for automatic tools and for humans 😃

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@EdoCrippaOfficial
Comment options

Answer selected by silversoul93
@silversoul93
Comment options

silversoul93 Apr 30, 2024
Collaborator Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
OSS Mia-Platform OpenSource Software projects related questions
2 participants