You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Logger doesn't report zone time when used in a fake_async zone #111
Logger does not report correct event origin time when executing in a zone created by fake_async due to LogEvent.time defaulting to DateTime.now().
This is technically not a bug since it's fake_async that requires all code that uses DateTime.now() to use clock.now() instead to work properly and allow overriding the current notion of time. See fake_async README.
This issue can be mitigated if all Logger.log and its level counterpart invocations are supplied with time: clock.now() in consumer code, but for large code bases this would take too much time for its limited value. Given that clock is a Dart-team package that should not introduce breaking changes neither for VM nor web environments, it seems it's a change that can be done quickly without any drawbacks.
Steps to reproduce
Implement a simple printer that adds formatted event origin time to a log message, then log inside of a fake_async callback with some time elapsed:
Resulting output is added underneath. You can see that formatted event time and clock.now() report different time (as expected), which is still bad for tests that rely on fake_async to control time passage.
I really like it and even though it adds a dependency, I think we can make an exception here (last breaking change is literally 7 years ago).
Feel free to go ahead and open a PR, I will try to review it as soon as I can.
changed the title [-]Logger doesn't report correct event time when used in a `fake_async` zone[/-][+]Logger doesn't report zone time when used in a `fake_async` zone[/+]on Mar 14, 2026
It is now merged, and I will probably release a new version soon.
I am just curious, but did you use AI to create the PR? :)
No, I am actually very late to the AI agent bandwagon and only touched Claude last month since it was forced at my main job last month. In my limited experience with Claude/Copilot, they're a bit bad with Dart-only projects and generate bogus code, especially tests. Maybe it takes more context for them to tune in.
Activity
alverone commentedon Mar 13, 2026
I am not aware of how
clockworks in a web environment, but since there are no listed gotchas in package README, I assume it shouldn't be an issue.Let me know if I should make a pull request (it's three lines of code)
Bungeefan commentedon Mar 14, 2026
Hi @alverone, thanks for the proposal!
I really like it and even though it adds a dependency, I think we can make an exception here (last breaking change is literally 7 years ago).
Feel free to go ahead and open a PR, I will try to review it as soon as I can.
[-]Logger doesn't report correct event time when used in a `fake_async` zone[/-][+]Logger doesn't report zone time when used in a `fake_async` zone[/+]alverone commentedon Mar 14, 2026
Renamed the issue since current behaviour is correct, just doesn't produce expected results in a different invocation context.
Bungeefan commentedon Mar 15, 2026
It is now merged, and I will probably release a new version soon.
I am just curious, but did you use AI to create the PR? :)
alverone commentedon Mar 16, 2026
No, I am actually very late to the AI agent bandwagon and only touched Claude last month since it was forced at my main job last month. In my limited experience with Claude/Copilot, they're a bit bad with Dart-only projects and generate bogus code, especially tests. Maybe it takes more context for them to tune in.