Skip to main content

cobalt_logging 1.7.0 copy "cobalt_logging: ^1.7.0" to clipboard
cobalt_logging: ^1.7.0 copied to clipboard

Cobalt adapter for package:logging — sends the DI graph's events to a dart.dev Logger.

example/example.md

cobalt_logging example #

Writes Cobalt's events into dart.dev's package:logging.

import 'package:cobalt/cobalt.dart';
import 'package:cobalt_logging/cobalt_logging.dart';
import 'package:logging/logging.dart';

Logger.root.level = Level.ALL;
Logger.root.onRecord.listen((record) => print(record));

final scope = await CobaltApplication.start(
  root: const AppScope(),
  observers: [CobaltLogObserver(CobaltLoggingSink())],
);

CobaltLogObserver turns typed events into CobaltLogRecords, and the sink writes them out; package:logging has no notion of a record type of its own, which is why this is a sink rather than a whole observer.

Do not confuse this package with cobalt_logger, one letter apart, which adapts package:logger instead.

0
likes
160
points
1.55k
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Cobalt adapter for package:logging — sends the DI graph's events to a dart.dev Logger.

Repository (GitHub)
View/report issues
Contributing

Topics

#dependency-injection #di #logging #observability

License

MIT (license)

Dependencies

cobalt, logging

More

Packages that depend on cobalt_logging