dart-lang / core

This repository is home to core Dart packages.
https://pub.dev/publishers/dart.dev
BSD 3-Clause "New" or "Revised" License
19 stars 7 forks source link

Add a log parameter for Metadata information #473

Open feinstein opened 2 years ago

feinstein commented 2 years ago

Many logging tools log Metadata with the traditional message, error and stack trace logs. Datadog is an example, it accepts a parameter called attributes, which is a json Map where you can send anything you want with your logs.

Crashlytics have an information field that usually uses FlutterErrorDetails.informationCollector to provide more data to the logs.

My project uses this library to route all the logs from the whole app to one central location, then we distribute the logs to Crashlytics and Datadog, but since the library doesn't have a parameter for Metadata we are losing depth on our logs.

My suggestion is that we add a Metadata parameter to the LogRecord and the log functions, to enrich the logs we can generate.

AmanNegi commented 2 years ago

Can I work on this issue?

Zekfad commented 1 year ago

Why not to use Expando to pass metadata with log record? I may be cumbersome, but compatible and doesn't require changing public API, it may even be implemented via extensions.

feinstein commented 1 year ago

Because besides being very cumbersome, making the log code harder to read, it will also won't work of you are logging strings, since you can't expand a string.

jaumard commented 3 months ago

That would be really useful to have this indeed, I'm currently implement remote logging with Google Cloud Logging for my Dart backend and I really miss a metadata attributes in order to send proper information to Cloud Logging