zooper_flutter_logging

Creator: coderz1093

Last updated:

0 purchases

TODO
Add to Cart

Description:

zooper flutter logging

This library provides a wrapper for loggers. Some examples are included.
Note: This library is part of the whole zooper lib family.
For more information see: https://pub.dev/packages/zooper_flutter_core
Getting started #
Add a new line inside your pubspec.yaml:
zooper_flutter_logging: <latest>
Usage #
To use the logger you have to instantiate at least 2 classes:
The log writer #
The logger needs a writer it can write the log to. This can be the console,
an api or a file. You can also define multiple writer which the logger writes to simultanously.
import 'package:flutter/foundation.dart';
import 'package:zooper_flutter_logging/zooper_flutter_logging.dart';

class ConsoleLogWriter extends LogWriter {
@override
Future writeAsync(String message) {
debugPrint(message);

return Future.value();
}
}
copied to clipboard
This is an example of a console writer which also can be found inside this package.
var writer = ConsoleLogWriter();
copied to clipboard
The logger #
After that, you need to pass the writer to the logger:
var logger = Logger(minimumLoggingLevel, _logWriter);
copied to clipboard
The minimumLoggingLevel defines what type of log should be logged. These options are available (starting from the lowest to the highest):
enum LogLevel {
verbose,
debug,
info,
warning,
error,
wtf,
}
copied to clipboard
The _logWriter expects a list of writers like our ConsoleWriter.
After all is set up, you can log messages like so:
logger.logInfoAsync('Your message');
copied to clipboard
or with StackTrace
logger.logInfoAsync('Your message', StackTrace.current);
copied to clipboard
or
logger.log('Your message', LogLevel.info, StackTrace.current);
copied to clipboard
Formatting the output #
Use the LogFormatter base class to dress up the output. An example class is also included named PrettyFormatter.
var formatter = PrettyFormatter();
copied to clipboard
Then you can pass it to our logger:
var logger = Logger(<minimumLoggingLevel>, <_logWriter>, formatter);
copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files:

Customer Reviews

There are no reviews.