Replies: 6 comments 2 replies
-
IMO this could be a simple nitro module for the start, and e.g. leverage hooks and similar to achieve app-wide logging 👍🏻 |
Beta Was this translation helpful? Give feedback.
-
As I see nitro modules are similar to nuxt modules - what a nice suprise 😄 |
Beta Was this translation helpful? Give feedback.
-
After checking it again I think the hook based implementation would not serves my goals. For example in my |
Beta Was this translation helpful? Give feedback.
-
https://github.com/pinojs/pino/blob/master/docs/web.md#pino-with-h3 can be on option without using KV Storage |
Beta Was this translation helpful? Give feedback.
-
You can also use consola's custom reporter and mix it with a global nitro middleware, but you won't be able to use unstorage since it does not allow appending content to a file |
Beta Was this translation helpful? Give feedback.
-
Yep, that is my point. It seems I have to use another package till unstorage has no append feature |
Beta Was this translation helpful? Give feedback.
-
I'd like to propose a new feature for Nitro: a (file) logger. This would allow developers to record events and data in production for later analysis.
Motivation
Debugging and Monitoring: In production environments, logs are crucial for troubleshooting issues and tracking application behavior. Having a dedicated (file) logger would provide a persistent record of events, making it easier to diagnose problems after the fact.
Task Results: When using Nitro tasks, there's often a need to capture the results and potentially send notifications, such as daily email summaries. A (file) logger would facilitate this by storing task outcomes for later retrieval.
Potential Implementation
Leveraging Nitro's existing KV storage capabilities, the (file) logger could be designed as follows:
New Function: append
This function would add a new log entry to the file without overwriting existing content.
Automatic Timestamping:
Each entry would include a timestamp for easy reference and ordering of events.
Extensibility through KV Storage:
By building upon Nitro's KV storage, the logger could offer flexibility in storage drivers.
I believe a (file) logger would be a valuable addition to Nitro's feature set.
There is already a similar discussion (#334), but that one is focusing on logging HTTP requests, and this one is more general. I guess if we have a solution for this one, it will likely solve that one as well.
Beta Was this translation helpful? Give feedback.
All reactions