slog_core 0.2.0 copy "slog_core: ^0.2.0" to clipboard
slog_core: ^0.2.0 copied to clipboard

A Basic Logger and Core for SLogs. A logger that wants to be more flexible.

SLog Core #

style: very good analysis License: MIT

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:

Install it:

dart pub get
flutter pub get

Install from terminal #

dart pub add slog_core
flutter pub add slog_core

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');
}

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
0
likes
150
points
27
downloads

Publisher

unverified uploader

Weekly Downloads

A Basic Logger and Core for SLogs. A logger that wants to be more flexible.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

async, meta, stack_trace

More

Packages that depend on slog_core