dart_log 1.2.0 dart_log: ^1.2.0 copied to clipboard
A simple dart console logger (release mode enabled/disabled and "limitless" characters)
A simple dart console logger (release mode enabled/disabled and "limitless" characters) #
Usage #
logger.d('message');
logger.e('message');
logger.i('message');
logger.w('message');
logger.trace('message');
logger.prod('message');
final tagLogger = logger.withTag('MY_TAG');
tagLogger.d('message'); // [MY_TAG]: message
logger.d('{"id": 123}', isJson: true);
/*
{
"id": 123
}
*/
// Log in release mode
logger.prod('message');
All logs enabled in release mode (using dart-define)
flutter build apk --release --dart-define dart_log_verbose="true"
Print max to "N" chars (useful with long api responses)
logger.d('long response from API', maxChars: 10000);
fileLinkLevel
: use this to get the link of the file that dispatched the log
// default = 3
logger.d('Link to file', fileLinkLevel: 3);
Interceptors
Use the DefaultLogInterceptor
or implement a custom LogInterceptor
Logger.interceptors.add(DefaultLogInterceptor((Object? data) {
print('ERROR: $data');
}, logTypes: [LogType.error]));