Created
April 5, 2021 14:53
-
-
Save fredgrott/7a3704d1d2b019c6ed0fdd30e46a2dfc to your computer and use it in GitHub Desktop.
logger mixins
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:base_riverpod/app/utils/logging/types.dart'; | |
import 'package:logging/logging.dart'; | |
// Works by setting the logger instance that we get in the class | |
// calling the mixin with a specific string name and thus allows | |
// a flexible setting what attributes of: | |
// error(cause) | |
// stackTrace | |
// level via logger suffix of finest, finer, fine, info, config, | |
// warning, severe, shout | |
// message | |
// zone | |
// | |
// color pens than are used at the logger line like this | |
// logger.info(penCyan('my message'), error, stackTrace) | |
mixin UiLogger implements LoggerType { | |
@override | |
Logger get logger => Logger('UI Logger - ${runtimeType.toString()}'); | |
} | |
mixin NetworkLogger implements LoggerType { | |
@override | |
Logger get logger => Logger('Network Logger - ${runtimeType.toString()}'); | |
} | |
mixin UtilityLogger implements LoggerType { | |
@override | |
Logger get logger => Logger('Utility Logger - ${runtimeType.toString()}'); | |
} | |
Logger logAFunction(String name) => Logger('$Logger.fullName.$name '); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment