notice 1.0.0-alpha.8 notice: ^1.0.0-alpha.8 copied to clipboard
An extensible logger with an intuitive tree-like structure. Notice excels in seamless cross-package logging while offering a simple yet robust API for developers.
Notice #
Notice is an extensible logger with an intuitive tree-like structure. Notice excels in seamless cross-package logging while offering a simple yet robust API for developers.
Simplest example #
final notice = Notice(
outputs: [
FilteredOutput(
LevelFilter(NoticeLevel.info),
ConsoleOutput(),
),
],
registries: [globalNoticeRegistry],
);
notice.info("Hello World");
notice.trace("Will not be logged");
final subNotice = Notice(parent: notice);
subNotice.info("Hello World pt. 2");
final thirdPartyNotice =
Notice(parent: globalNoticeRegistry, breadcrumb: "FooPackage");
thirdPartyNotice.error("Hello World from another package");
final thirdPartySubPackage =
Notice(parent: thirdPartyNotice, breadcrumb: "BarProcessing");
thirdPartySubPackage.warn("Sub log from another package");
// 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
Extensible #
Create your own implementation of filters and outputs to extend the behaviour of this package
Roadmap #
- Sentry support
in fact, sentry support already exists but i have to change this project to a mono-repo structure first, before moving the output implementation here - Improve output formatting
Add colors and possibly borders to the output. This will also include a formatting interface for better code seperation and customizability. - Adapters to most of the common dart loggers
To improve the experience when switching to notice and not make package authors clients dependent on it