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:
2026-05-27 12:01:39 +02:00
committed by GitHub
parent 45de68683b
commit ebbe8d99ad
6 changed files with 98 additions and 17 deletions
@@ -110,9 +110,37 @@ class RedactingLogInterceptor implements LogInterceptor {
}
}
class TestLoggerWithLoggerName extends LoggingInterface with LoggerName {
@override
String get name => "test-logger";
final List<LogEvent> events = [];
@override
void log(
String message, {
Map<String, Object?>? metadata,
Level? level,
StackTrace? stackTrace,
Object? extra,
}) {
events.add(
LogEvent(
message: message,
metadata: metadata == null ? null : Map<String, Object?>.from(metadata),
level: level,
stackTrace: stackTrace,
extra: extra,
),
);
}
}
void main() {
late TestLoggingInterface myInterface;
late LogInterceptor prefixInterceptor;
final TestLoggerWithLoggerName loggerWithLoggerName =
TestLoggerWithLoggerName();
setUp(() {
Arcane.logger.reset();
@@ -677,4 +705,12 @@ void main() {
});
});
});
test("LoggerName mixin exposes name at runtime", () {
expect(loggerWithLoggerName.name, "test-logger");
loggerWithLoggerName.log("Test message");
expect(loggerWithLoggerName.events.length, 1);
expect(loggerWithLoggerName.events.first.message, "Test message");
});
}