journal 0.3.0 copy "journal: ^0.3.0" to clipboard
journal: ^0.3.0 copied to clipboard

A simple log writer and subscriber usable both from libraries and applications.

example/lib/main.dart

import 'dart:async';

import 'package:journal/journal.dart';

void main() async {
  Journal.minimumLevel = JournalEntryLevel.trace;
  Journal.autoCaptureZones = true;
  Journal.forceFormatTerminalOutput = true;
  Journal.outputs = const [DefaultJournalOutput(displayZone: true)];

  const journal = Journal('example');

  for (final level in JournalEntryLevel.values) {
    if (level != JournalEntryLevel.error) {
      journal.log(level, 'This is a log message.', values: {
        'bool': true.toJournal,
        'int': 42.toJournal,
        'double': 3.14.toJournal,
        'string': 'value'.toJournal,
        'iterable': [1, 2, 3].map(JournalValue.int).toJournal,
        'entries': {'a': 1, 'b': 2, 'c': 3}.map((key, value) {
          return MapEntry(key, value.toJournal);
        }).toJournal,
      });
    }
  }

  runZoned(() {
    try {
      throw const FormatException('this does not seem right');
    } on FormatException catch (ex, trace) {
      journal.error('Caught an error.', values: {'error': ex.toString().toJournal}, trace: trace);
    }
  }, zoneValues: const {zoneNameKey: 'error-zone'});
}
3
likes
140
points
61
downloads

Publisher

verified publisherskreborn.me

Weekly Downloads

A simple log writer and subscriber usable both from libraries and applications.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

ffi, logging, meta, stack_trace, web

More

Packages that depend on journal