dd-sdk-flutter icon indicating copy to clipboard operation
dd-sdk-flutter copied to clipboard

I would like to request the ability to attach datetime to the log method in ddlogs.

Open rouddy opened this issue 8 months ago • 2 comments

Feature description

  1. Use case
DatadogLogger.log(
    LogLevel level,
    String message, {
    String? errorMessage,
    String? errorKind,
    StackTrace? errorStackTrace,
    Map<String, Object?> attributes = const {},
  })
  1. Currently deliversIn iOS and Android libraries, you can directly set the date information of the log explorer by attaching a Date object with the "date" key to the attribute, but this is not possible in the flutter library.
void handleLog(LogRecord record) {
    if (record.level.value >= level.level.value) {
      logger.log(
          record.level.ddLevel, record.message,
          errorKind: record.error?.runtimeType.toString(),
          errorMessage:
              record.error != null ? Error.safeToString(record.error) : null,
          errorStackTrace: record.stackTrace,
          attributes: {
            "date": record.time,
          });
    }
  }

this code returns next error

[Datadog 🐶⚠️ ] ArgumentError when calling logs._internalLog: parameter null. It looks like date is of type DateTime, which is not supported.

and with i tried various string formatting with datetime but it does not affect to log explorer.

  1. I want set datetime of log explorer.

Proposed solution

Modify the internalLog method of the DatadogLogsPlugin.kt file to perform Date parse for strings with the "date" key in the context.

or

accept date string on back end.

Other relevant information

No response

rouddy avatar Mar 26 '25 05:03 rouddy