writeBuildLog function

Future<void> writeBuildLog(
  1. String buildJobId,
  2. String runId,
  3. LogLevel level,
  4. String message, {
  5. String? stackTrace,
})

Implementation

Future<void> writeBuildLog(
  String buildJobId,
  String runId,
  LogLevel level,
  String message, {
  String? stackTrace,
}) async {
  final group = _getBufferGroup(buildJobId, runId);
  group.entries.add(
    LogEntry(
      id: _uuid.v4(),
      message: message,
      level: level,
      timestamp: DateTime.now().toUtc().toIso8601String(),
      stackTrace: stackTrace,
    ),
  );

  if (group.entries.length >= _maxBufferCount) {
    _triggerFlush(group);
  } else {
    group.timer ??= Timer(_flushInterval, () => _triggerFlush(group));
  }
}