aissat / easy_localization

Easy and Fast internationalizing your Flutter Apps
https://pub.dev/packages/easy_localization
MIT License
881 stars 312 forks source link

Allow using your own logger #697

Open Hannnes1 opened 6 days ago

Hannnes1 commented 6 days ago

This issue is based on an idea mentioned in #374.

EasyLocalization is currently tightly coupled to EasyLogger. This is an issue for apps that want to use a different logger, or want to log to something other than the console (for example Firebase Crashlytics or Sentry).

The only way around this limitation right now is to customize EasyLocalization.logger.printer, but that still relies on EasyLogger.

I suggest creating a callback parameter (e.g. onEvent) in EasyLocalization that by default passes the events to EasyLogger for compatibility. The internal easyLocalization code should then call this new onEvent parameter instead of EasyLocalization.logger; perhaps using some private helper function that is similar to the existing logging methods.

This approach would allow users to use any logging framework that they want, without having to go through EasyLogger.