Logger
Small, easy to use and extensible logger which prints beautiful logs.
Inspired by logger for Android.
Inspired by logger for Android.
Getting Started
Just create an instance of
Logger
and start logging:
Instead of a string message, you can also pass other objects like
List
, Map
or Set
.Output
Log Console
If you are creating a Flutter app, you can use the logger_flutter extension. Shake the phone to show an on device console.
Documentation
Log level
You can log with different levels:
To show only specific log levels, you can set:
This hides all
verbose
, debug
and info
log events.Options
When creating a logger, you can pass some options:
If you use the
PrettyPrinter
, there are more options:LogFilter
The
The default implementation (
LogFilter
decides which log events should be shown and which don't.The default implementation (
DebugFilter
) shows all logs with level >= Logger.level
while in debug mode. In release mode all logs are omitted.
You can create your own
LogFilter
like this:
This will show all logs even in release mode. (NOT a good idea)
LogPrinter
The
You can implement your own
LogPrinter
creates and formats the output, which is then sent to the LogOutput
.You can implement your own
LogPrinter
. This gives you maximum flexibility.
A very basic printer could look like this:
Important: Every implementation has to send its output using the
println()
method.
If you created a cool
LogPrinter
which might be helpful to others, feel free to open a pull request. :)LogOutput
LogOutput
sends the log lines to the desired destination.The default implementation (
ConsoleOutput
) send every line to the system console.
Possible future
LogOutput
s could send to a file, firebase or to Logcat. Feel free to open pull requests.logger_flutter extension
The logger_flutter package is an extension for logger. You can add it to any Flutter app. Just shake the phone to show the console.
- Add logger_flutter to your
pubspec.yaml
- Add the following code into your widget tree
More documentation coming soon.