搜尋套件、儲存庫與 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 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。