captureLog method

void captureLog(
  1. String message, {
  2. String? level,
  3. String? tag,
  4. DateTime? timestamp,
})

Writes a log entry directly into the SDK's log buffer.

Use this to forward messages from third-party loggers (such as package:logging, package:logger, or package:talker) so they appear in the console-logs.txt attachment alongside print() output and Flutter framework errors.

  • message: the log message text.
  • level: optional severity label (e.g. "info", "warning", "severe"). Pass the value your logging library already produces.
  • tag: optional category or logger name (e.g. "AuthService").
  • timestamp: optional point-in-time for the entry. Defaults to now.

Example — wiring package:logging:

Logger.root.onRecord.listen((record) {
  Critic.instance.captureLog(
    record.message,
    level: record.level.name,
    tag: record.loggerName,
    timestamp: record.time,
  );
});

Implementation

void captureLog(
  String message, {
  String? level,
  String? tag,
  DateTime? timestamp,
}) {
  logCapture.buffer.add(
    message,
    level: level,
    tag: tag,
    timestamp: timestamp,
  );
}