mirror of
https://github.com/hanskokx/arcane_framework.git
synced 2026-08-14 07:10:59 +02:00
v2.0.2: Fix ArcaneLogger LoggerName mixin to be runtime safe (#9)
* Enhance reset method in ArcaneLogger to clear interceptors along with metadata and interfaces Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com> * Update Logging feature to replace @LoggingFeature annotation with LoggerName mixin for runtime accessibility Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com> * Bump version to 2.0.2 in pubspec.yaml and update CHANGELOG to reflect the new version Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com> * Add migration steps for replacing @LoggingFeature annotation with LoggerName mixin in CHANGELOG Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com> * Add TestLoggerWithLoggerName class to enhance logging functionality and verify LoggerName mixin behavior Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com> * Fix class declaration in migration example for LoggerName mixin Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com> --------- Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
@@ -41,13 +41,24 @@ mixin LoggingInitialization implements LoggingInitializable {
|
||||
}
|
||||
}
|
||||
|
||||
/// Annotation used to tag a logging destination with a feature name.
|
||||
/// Opt-in mixin that exposes a [name] string on a [LoggingInterface].
|
||||
///
|
||||
/// Mix this into a concrete logger to declare what [name] should be associated
|
||||
/// with this logging interface.
|
||||
///
|
||||
/// Example:
|
||||
/// `@LoggingFeature("analytics")`
|
||||
final class LoggingFeature {
|
||||
const LoggingFeature(this.value);
|
||||
|
||||
/// The feature name associated with this logging destination.
|
||||
final String value;
|
||||
/// ```dart
|
||||
/// class MyLogger extends LoggingInterface with LoggerName {
|
||||
/// @override
|
||||
/// String get name => 'my-feature';
|
||||
///
|
||||
/// @override
|
||||
/// void log(String message, {...}) {
|
||||
/// print('[$name] $message');
|
||||
/// }
|
||||
/// }
|
||||
/// ```
|
||||
mixin LoggerName on LoggingInterface {
|
||||
/// The name associated with this logging interface.
|
||||
String get name;
|
||||
}
|
||||
|
||||
@@ -470,8 +470,8 @@ class ArcaneLogger {
|
||||
void clearPersistentMetadata() => _additionalMetadata.clear();
|
||||
|
||||
/// Resets the Arcane logging service by clearing all persistent metadata,
|
||||
/// clearing all registered [LoggingInterface]s and marking the logging
|
||||
/// service as no longer being initialized.
|
||||
/// clearing all registered [LoggingInterface]s, clearing all interceptors,
|
||||
/// and marking the logging service as no longer being initialized.
|
||||
void reset() {
|
||||
dispose();
|
||||
I._interfaceRegistrations.clear();
|
||||
|
||||
Reference in New Issue
Block a user