Search code examples
flutterdartimportlocalizationdart-pub

Flutter: How to set easy_localization logging log level


I want to set the log level of easy_localization in a Flutter application. I tried to do this by setting the EasyLocalization.logger.defaultLevel enum, however the enum is stored in the local Pup cache and I couldn't find a good way to import it into the file to get access to it.

I tried setting a integer value and casting to dynamic but this did not work either.

Is there a way to import this enum, or otherwise set the log level with this package?


Solution

  • easy_localization is using the easy_logger package to print log messages.

    If you want to set the log level for easy_localization you also have to add the easy_logger package. To do so run:

    flutter pub add easy_logger
    

    Now you can import the easy_logger package and access the LevelMessages class:

    import 'package:easy_localization/easy_localization.dart';
    import 'package:easy_logger/easy_logger.dart';
    
    void main() {
      EasyLocalization.logger.defaultLevel = LevelMessages.info;
    }