via_logger 1.0.4 copy "via_logger: ^1.0.4" to clipboard
via_logger: ^1.0.4 copied to clipboard

Logger for Dart applications, the printed log contains time, file name, and line number, allows you create your own log.

via_logger #

Language: English|中文简体

Why was this library created? #

In the daily development process, the log is the most convenient clue for us to find bugs. However, the print log that comes with Flutter does not print the time, file name, and line number. This caused us inconvenience to find the problem quickly. Portal via_logger

Features #

  • ✅ Print log level, time, file path and line number.
  • ✅ Print long log.
  • ✅ Filter logs based on log level.
  • ✅ Custom print content.

Install #

dependencies:
  via_logger:

how to use? #

1. Simple to use #

Import the package, you can use it directly, what you see is what you get.

import 'package:via_logger/via_logger.dart';

Logger.info('this is info log.');

Printed out is:
2021-12-23 15:07:51.066223 [package:/test/main.dart:123] this is info log.

2. Set the log level #

In debug mode, all logs are printed by default; in product mode, all logs are closed by default.

///If the log level is set to info, only logs with a level above INFO will be displayed.
Logger.minLevel = Level.INFO;

3. Custom log output #

a. Create a subclass that inherits Output and override the output method

class Console extends Output {
  @override
  void output(LogRecord record) {
    ///Custom print style
    print('${record.time [${record.path}:${record.lineNumber}] ${record.message}');
  }
}

b. Set output engine

When the app is initialized, set the output engine.

final List<Output> engines = [Console()];
Logger.setEngines(engines);
2
likes
140
points
33
downloads

Publisher

unverified uploader

Weekly Downloads

Logger for Dart applications, the printed log contains time, file name, and line number, allows you create your own log.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on via_logger