SourceHorizon / logger

Small, easy to use and extensible logger which prints beautiful logs.
https://pub.dev/packages/logger
MIT License
197 stars 33 forks source link

--enable-asserts shows message on screen #41

Closed cyryl1972 closed 1 year ago

cyryl1972 commented 1 year ago

When I ran example "example/main.dart":

dart ./example/main.dart -> no message are printed on screen (messages are printed in debug console)

dart --enable-asserts ./example/main.dart -> messages are printed on screen

Can you explain me why? is that behaviour normal?

Bungeefan commented 1 year ago

Hi, yes this is normal and intended.

The reason behind this behavior is the default DevelopmentFilter, as it always returns false when asserts are not enabled. The intention behind this was probably to prevent logging in production environments, for example, in Flutter asserts are only run during debug mode and this filter reduces the performance impact from logging while running the app in release mode on a real device where logs usually aren't accessible anyway.

However, you can change that behavior by using your own filter or the ProductionFilter, which always checks the level even without asserts.

Hope this answers your questions :)

cyryl1972 commented 1 year ago

hi,

Sorry for my late answer. I understand the concept behind the scene.

You perfectly answered to my question. Have a good day.