write method

  1. @override
void write(
  1. String name,
  2. JournalEntry entry
)
override

Writes entry for name.

Implementation

@pragma('vm:always-consider-inlining')
@override
void write(String name, JournalEntry entry) {
  // ignore: unused_result
  final priority = switch (entry.level) {
    JournalEntryLevel.trace => 2,
    JournalEntryLevel.debug => 3,
    JournalEntryLevel.info => 4,
    JournalEntryLevel.warn => 5,
    JournalEntryLevel.error => 6,
  };

  final tag = [
    name,
    if (displayZone) '[${entry.zone.name}]',
  ];

  final trace = entry.trace;

  final message = [
    entry.message,
    for (final entry in entry.values.entries) ' ${entry.key}=${entry.value}',
    if (displayTrace && trace != null)
      Trace.from(trace)
          .terse
          .alignedFrames
          .map((frame) => 'at ${frame.location} in ${frame.member}')
          .join('\n'),
  ];

  using((arena) {
    _logWrite(
      priority,
      tag.join().toNativeUtf8(allocator: arena),
      message.join().toNativeUtf8(allocator: arena),
    );
  });
}