notice 1.0.0-alpha.3 notice: ^1.0.0-alpha.3 copied to clipboard
Another logger with a focus on simplicity and cross-package logging.
Notice (The package name, not a warning) #
Another logger with a focus on simplicity and cross-package logging.
Simplest example #
final notice = Notice(
outputs: [ConsoleOutput()],
);
notice.info("Hello World");
// prints: 2023-12-11T20:00:28.495978 INFO: Hello World
Creating sub-loggers #
Always know where the message came from using breadcrumbs
final notice = Notice(
outputs: [ConsoleOutput()],
breadcrumb: "main"
);
final subNotice = Notice.childOf(notice, breadcrumb: "foo");
subNotice.info("Sub Logger message");
// prints: 2023-12-11T20:03:28.048468 main.foo INFO: Sub Logger message
Filtering messages #
If you need multiple filters you can also use `CombinedFilter``
final notice = Notice(outputs: [
FilteredOutput(
LevelFilter(NoticeLevel.info),
ConsoleOutput(),
),
]);
notice.info("Will be logged");
notice.warn("Will also be logged");
notice.trace("Will not be logged");
// prints:
// 2023-12-11T20:18:26.721386 INFO: Will be logged
// 2023-12-11T20:18:26.723331 WARN: Will also be logged
Third-Party-Package logging #
final notice = Notice(
outputs: [ConsoleOutput()],
registries: [globalNoticeRegistry],
);
final thirdPartyPackageNotice = Notice(
parent: globalNoticeRegistry,
breadcrumb: "BarPackage",
);
thirdPartyPackageNotice.error("Error from another package");
// prints: 2023-12-11T20:09:51.188054 BarPackage ERROR: Error from another package