leancode_logging_flutter 1.0.0

Flutter Android iOS

Common Flutter logging utilities

leancode_logging_flutter #

Logging utilities for Flutter.

This library contains loggers that can be used in a Flutter app:

  • Bugfender logger
  • Console logger

Using the package in app #

Define a global variable in you app to access the logger:

final bugfender = Bugfender(config.bugfenderKey, config.debugMode);
logger = bugfender;

or

final consoleLogger = ConsoleLogger(config.debugMode);
logger = consoleLogger

This will allow you to use logger throughout your application easily, for example:

try {
    //do something
} catch (e, s) {
    logger.logException(e, s);
}

To see all available methods take a look at API reference.

Bugfender logger #

Using Bugfender logger requires initialization of the Bugfender plugin.

final bugfender = Bugfender(config.bugfenderKey, config.debugMode);
bugfender.init();

Using the package in tests #

Logger can be used in tests without dependency on Flutter itself. This way you can have your tests running with just Dart without Flutter.

In order to do that you need to override logger variable in test setup. When using mockito you can provide a simple mock, for example:

// define simple mock
class FakeLogger extends Mock implements Logger {}

// and then use in setup:
logger = FakeLogger();