搜索插件、代码仓与 APP 分类

roggle 封面
插件详情v0.4.2+1

roggle

适用于 Dart 的简单、多彩且易于扩展的日志记录器。受 logger 启发,并依赖于 logger。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
254
喜欢数
33
Pub 分数
130

安装插件

flutter pub add roggle

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

Roggle 是一个简单、色彩丰富且易于扩展的 Dart 日志包,灵感来自流行的日志库。它提供了一个简洁直观的 API,可在 Android、iOS、Web、macOS、Windows 和 Linux 等多个平台上输出日志。通过鲜艳的颜色编码和可自定义的格式,Roggle 在不增加复杂性的情况下提升了调试可见性。其轻量级设计使其非常适合开发和生产环境使用,尤其适合希望在最小设置下获得视觉上鲜明的日志体验的开发者。该包可通过 pub.dev 无缝集成到 Flutter 项目中。

适合场景

  • 调试应用程序流程
  • 监控运行时行为
  • 提高开发中的日志可读性
  • 跨平台日志记录
  • 快速集成到现有项目中
  • 日志级别视觉区分

主要特点

  • 彩色控制台输出
  • 简单直观的 API
  • 可扩展的设计
  • 多平台支持
  • 最小配置
  • 日志级别过滤

适合对象

  • 寻求视觉日志清晰度的开发者
  • 需要轻量级日志记录的 Flutter 应用
  • 重视开发者体验的团队
  • 需要易于阅读的调试输出的项目
  • 快速原型设计,反馈清晰
  • 简单日志记录,无重型依赖

使用建议

  • 不适合高容量生产日志
  • 与功能齐全的记录器相比,高级功能有限
  • 颜色输出在非终端环境中可能没有用处
  • 依赖外部日志记录器提供核心功能
  • 可能需要为自定义格式化程序进行额外配置
  • 最适合在开发或低吞吐量场景中使用

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

logo

Roggle

Test codecov MIT

Simple, colorful and easy to expand logger for dart.
Inspired by the logger and dependent to the logger.

Getting Started

Just create an instance of Roggle and start logging:

import 'package:roggle/roggle.dart';

final logger = Roggle();

logger.d('Roggle is working!');

Instead of a string message, you can also pass other objects like List, Map, Set or Function.

Output

Android Studio

Documentation

Roggle's API is almost the same as the logger. See the logger for basic usage.

Difference from the logger

  • Printer defaults to SinglePrettyPrinter class.
  • Not try-catch at LogOutput class, because we want to stop the process.
  • Added some getters in Roggle class.
  • Changed the log interface dynamic to Object?.

Options

If you use the SinglePrettyPrinter, there are more options:

final logger = Roggle(
  printer: SinglePrettyPrinter(
    loggerName: '[APP]', // Print a logger name for each log message
    colors: true, // Colorful log messages
    printCaller: true, // Print a caller for each log message
    printLocation: true, // Print a location of caller for each log message
    printFunctionName: true, // Print a function name of caller for each log message
    printEmojis: true, // Print an emoji for each log message
    printLabels: true, // Print a level string for each log message
    printTime: true, // Print a timestamp for each log message
    stackTraceLevel:
        Level.error, // The current logging level to display stack trace
    stackTraceMethodCount: 10, // Number of stack trace methods to display
    stackTracePrefix: '>>> ', // Replace stack trace prefix
    levelColors: {}, // Replace level colors map
    levelEmojis: {}, // Replace level emojis map
    levelLabels: {}, // Replace level labels map
    timeFormatter: (now) => DateFormat('yyyy/MM/dd HH:mm:ss.SSS')
        .format(now), // Replace time formatter
  ),
);

SinglePrettyPrinter

You can use the Roggle.crashlytics() to send errors and logs using the FirebaseCrashlytics API in release mode.

final logger = Roggle.crashlytics(
  printer: CrashlyticsPrinter(
    errorLevel: Level.error, // Logs above this level will call onError
    onError: (event) {
      // Send an error to Firebase Crashlytics as follows
      FirebaseCrashlytics.instance.recordError(
        event.exception,
        event.stack,
        fatal: true,
      );
    },
    onLog: (event) {
      // Send logs to Firebase Crashlytics as follows
      FirebaseCrashlytics.instance.log(event.message);
    },
    loggerName: '[APP]',
    printCaller: true, // Print a caller for each log message
    printLocation: true, // Print a location of caller for each log message
    printFunctionName: true, // Print a function name of caller for each log message
    printEmojis: true, // Print an emoji for each log message
    printLabels: true, // Print a level string for each log message
    levelEmojis: {}, // Replace level emojis map
    levelLabels: {}, // Replace level labels map
  ),
);

Tips

If you want to stop the process at the same time as the error log, do the following.

import 'package:roggle/roggle.dart';

final logger = Roggle(
  output: AssertionOutput(),
);

class AssertionOutput extends ConsoleOutput {
  @override
  void output(OutputEvent event) {
    super.output(event);
    if (event.level.index >= Level.error.index) {
      throw AssertionError('Stopped by logger.');
    }
  }
}

License

MIT License

Copyright (c) 2022 Keyber Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

所属分类

依赖

依赖清单 3 项

源码仓库

使用此插件的项目

暂无相关数据。