0 purchases
slog core
SLog Core #
This is the core package, but it does contain a base logger which you don't need to use, create your own that's the
point of having the core package.
Features #
Base Logger
Printers
Interceptors
Channels
Logger isolate
Installation #
Added it directly #
Add slog_core to your pubspec.yaml:
dependencies:
slog_core:
copied to clipboard
Install it:
dart pub get
copied to clipboard
flutter pub get
copied to clipboard
Install from terminal #
dart pub add slog_core
copied to clipboard
flutter pub add slog_core
copied to clipboard
Basic Logger #
The basic logger is globally available and uses the singleton pattern. You can create your on instance non-singleton
instance just call the constructor for Logger.
import 'package:slog_core/logger.dart';
main() {
//You can initialize the Basic Logger if you want,
//but by default it is already initialized with no options.
//It is recommended to init the logger with at least one printer as there is no printer by default.
Logger.init();
//or
Logger.init(
options: SLogOptions(
printers: [
SomePrinter(), //not a real printer, see slog_basic for per-made printers
],
),
);
Logger.I.log('Hello world');
//or
Logger.instance.log('Hello world');
}
copied to clipboard
Some notes #
Errors #
If the logger, printers or interceptors throw an error the SLogger will try to not bubble them up to the main thread.
Like if a jsonEncode or jsonDecode throw an error inside a printer, the logger will catch the error and print a
message to dart log.
Loggers #
Because this package was built with customization in mind. You can add your own Levels, create a new logger by
extending the SLogger, it is recommended that you create your own interceptors and printers as we can't guess your use
case.
Motivation #
Yes I know there are a lot of logger out there I'm not saying mine is better, I'm saying that it has functionality I
want in a logger, like having multiple printers and allow for interceptors like what dio
or chopper has. Why should it be exclusive to HTTP clients?
TODO #
✓ Interceptors: see slog_basic
✓ Printers: see slog_basic
Filters
UI package for flutter
Local server package
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.