logging
logging copied to clipboard
logging: provide LogRecord formatting
<img src="https://avatars.githubusercontent.com/u/444270?v=3" align="left" width="96" height="96"hspace="10"> Issue by seaneagan Originally opened as dart-lang/sdk#12030
The logging package should provide support for converting LogRecords into Strings.
In Java's logback these are called Layouts:
http://logback.qos.ch/manual/layouts.html
For example:
class LogFormat { String format(LogRecord record); }
Then can use it like so:
logger.onRecord.map(logFormat.format)
<img src="https://avatars.githubusercontent.com/u/2909286?v=3" align="left" width="48" height="48"hspace="10"> Comment by madsager
cc @sigmundch. cc @gramster. Added Area-Library, Triaged labels.
<img src="https://avatars.githubusercontent.com/u/4865287?v=3" align="left" width="48" height="48"hspace="10"> Comment by lrhn
Removed Type-Defect label. Added Type-Enhancement, Library-Logging labels.
<img src="https://avatars.githubusercontent.com/u/4865287?v=3" align="left" width="48" height="48"hspace="10"> Comment by lrhn
Removed Area-Library label. Added Area-Pkg label.
<img src="https://avatars.githubusercontent.com/u/3276024?v=3" align="left" width="48" height="48"hspace="10"> Comment by anders-sandholm
Removed Library-Logging label. Added Pkg-Logging label.
There are other issues that are pointing to this. Can one of the core maintainers specify a list of features that requires implementation so that someone can work on them?
Logs from apps running on cloud services like GCP Logging, are usually expected to be in a structured format. So having the ability to use custom formatters for logs would be helpful for parsing and setting alerts.
Can one of the core maintainers specify a list of features that requires implementation so that someone can work on them?
I don't think we have done that level of triaging, and I'm not sure we'll realistically be able to any time soon.
having the ability to use custom formatters for logs would be helpful for parsing and setting alerts.
There are not any blockers to you defining custom formatters. The main question is whether there are formats that are universal enough to warrant shipping in the shared package. So far I'm not convinced there are - I don't think we could define a format that enough folks would want to make it worth defining here instead of defining elsewhere. It would also be easy for someone to write an external package like package:log_format
that exposes one or more String Function(LogRecord)
for reuse.