flogger 0.0.8 copy "flogger: ^0.0.8" to clipboard
flogger: ^0.0.8 copied to clipboard

Flogger is a simple yet powerful logging library for Dart applications.

Flogger Dart Library #

Description #

Flogger is a simple yet powerful logging library for Dart applications. It supports various logging levels, such as debug, info, warning, and error, and provides beautifully formatted console output. This library is ideal for those who wish to keep track of activities within their application, find bugs, or monitor app performance.

Features #

  • Supports logging for debug, info, warning, and error levels.
  • Thread and source caller information.
  • Predefined log message templates with customizable tags.
  • Global toggling of log status.
  • Utilizes Dart's developer logging capabilities.

Installation #

To include this package in your Dart project, add it to your pubspec.yaml file:

dependencies:
  flogger: ^latest_version

Then run pub get.

Usage #

First, import the package in your Dart code:

import 'package:flogger/flogger.dart';

Here are a few ways to use the library:

Debug Log #

// Singleton
  var log = Flogger();

log.d(DateTime.now());
/*
[πŸ› [DEBUG]:  FloggerTag]
╔═════════════════════════════════════════════════════════════════════════════════════╗
β•‘Thread: main, Source: #2      ExampleController.chooseDate (example/main.dart:13:13) β•‘
β•Ÿβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β•’
β•‘ 2023-09-16 23:43:16.678749                                                          β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
*/

Warning Log with Custom Tag #

log.w("Warning message", tag: "WarningTag");
/*
[️ [WARNING]: WarningTag]
╔═════════════════════════════════════════════════════════════════════════════════════╗
β•‘Thread: main, Source: #2      ExampleController.clickButton (example/main.dart:16:18)β•‘
β•Ÿβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β•’
β•‘ Warning message                                                                     β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
*/

Error Log #

log.e({"error":"msg error" , "status": 404});
/*
[❌ [ERROR]:  FloggerLogs]
╔═══════════════════════════════════════════════════════════════════════════════════════╗
β•‘Thread: main, Source: #2      ExampleController.requestServer (example/main.dart:13:13)β•‘
β•Ÿβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β•’
β•‘{error: msg error, status: 404}                                                                                                      β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
*/

API #

Global Configurations #

  • isLoggingEnabled: Boolean to enable or disable logging globally.
  • globalLogTag: A string used as the global tag for the log if no tag is specified in the individual log methods.

Methods #

  • d(Object? obj, {String? tag}): Logs a debug message.
  • i(Object? obj, {String? tag}): Logs an info message.
  • w(Object? obj, {String? tag}): Logs a warning message.
  • e(Object? obj, {String? tag}): Logs an error message.

Contributions #

Contributions, issues, and feature requests are welcome!

License #

This project is licensed under the MIT License.

1
likes
135
pub points
63%
popularity

Publisher

unverified uploader

Flogger is a simple yet powerful logging library for Dart applications.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on flogger