JSON support in loggers
Closed this issue · 4 comments
Is your feature request related to a problem? Please describe.
Logging services - in my case logtail - are increasingly involved in parsing logs and giving access to structured logs. The most straightforward option is to log JSON, though some also support logfmt.
The Deno logging module is great, but it doesn't work for logging JSON: at an early stage, it stringifies anything that is logged:
https://deno.land/std@0.188.0/log/logger.ts?source#L95
Describe the solution you'd like
I'd prefer the stringify step in the logging module to be at the handler stage, not at the logger stage, so that a JSONHandler
, similar to ConsoleHandler
, could be written in userspace.
Describe alternatives you've considered
There are other logging modules, but it'd be nice to use the Deno-std one.
I can take this one and check out possibilities for a JSONHandler
💯 This is especially relevant now that #golang added https://pkg.go.dev/log/slog for structured logging. Also, it seems the std logger is slightly unconventional to use warning
instead of warn
method; the latter of which is more common in javascript.
The JSON logging PR has been merged now, could we consider this issue closed?