0 purchases
easy logger
EasyLogger
Getting Started #
🔩 Installation #
Add to your pubspec.yaml:
dependencies:
easy_logger: <last_version>
copied to clipboard
⚙️ Configuration logger #
Create global logger value
import 'package:easy_logger/easy_logger.dart';
final EasyLogger logger = EasyLogger(
name: 'NamePrefix',
defaultLevel: LevelMessages.debug,
enableBuildModes: [BuildMode.debug, BuildMode.profile, BuildMode.release],
enableLevels: [LevelMessages.debug, LevelMessages.info, LevelMessages.error, LevelMessages.warning],
);
void main() async {
...
}
copied to clipboard
📜 EasyLogger properties #
Properties
Required
Default
Description
name
false
''
Name prefix in the logging line.
defaultLevel
false
LevelMessages.info
Default message level if no level is set when call [EasyLogger].
enableBuildModes
false
[BuildMode.debug, BuildMode.profile]
List of available build modes in which logging is enabled.
enableLevels
false
[LevelMessages.debug, LevelMessages.info, LevelMessages.error, LevelMessages.warning]
List of available levels messages in which logging is enabled.
printer
false
easyLogDefaultPrinter()
Default function printing.
Usage #
Simle usage:
logger('Your log text');
copied to clipboard
Or you can set the message level
logger('Your log text', level: LevelMessages.info);
copied to clipboard
🐛 StackTrace #
[EasyLogger] support [StackTrace] dump sending:
try {
//same code
} on Exception catch (e, stackTrace) {
logger('same error', stackTrace: stackTrace);
}
copied to clipboard
🖨️ Customise message or build levels #
[EasyLogger] supported Flutter build modes. Read more about Build modes
// only debug and profile modes
logger.enableBuildModes = [BuildMode.debug, BuildMode.profile]
// logger off
logger.enableLevels = []
copied to clipboard
You can customize what levels of messages you need
// show only errors
logger.enableBuildModes = [LevelMessages.error]
copied to clipboard
🖨️ Customise printer function #
[EasyLogger] have easiest way to change default printer function.
Create your custom printer and past like parameter in class.
EasyLogPrinter customLogPrinter = (
Object object, {
String name,
StackTrace stackTrace,
LevelMessages level,
}) {
print('$name: ${object.toString()}');
};
final EasyLogger logger = EasyLogger(
printer: customLogPrinter,
);
copied to clipboard
Or insert into class object
logger.printer = customLogPrinter;
copied to clipboard
🖨️ Helpers #
For easest using logger you can send messages without level parameter.
logger.debug('your log text');
logger.info('your log text');
logger.warning('your log text');
logger.error('your log text');
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.