搜尋套件、儲存庫與 APP 分類

quick_log 封面
套件詳情v5.5.3

quick_log

一個容易使用且可擴展的 Dart 日誌套件。特別適用於庫中使用,因為它允許應用程式控制導入庫的日誌記錄。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
4910
喜歡數
21
Pub 分數
150

安裝套件

flutter pub add quick_log

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

Quick Log 是一個輕量級、可擴展的 Dart 日誌套件,專為簡潔與彈性設計。它讓程式庫能夠輸出日誌,並由主應用程式進行控制,非常適合用於共享程式碼中的除錯與監控。支援所有主要平台,提供一致的日誌體驗。此套件允許開發者自訂日誌層級、輸出格式與目的地,同時維持極小的開銷。其模組化設計使其容易整合至現有專案。

適用情境

  • 庫級日誌記錄
  • 跨平台除錯
  • 執行時期日誌控制
  • 應用監控
  • 錯誤追蹤
  • 開發時診斷

主要特色

  • 可設定的日誌等級
  • 可擴展的後端系統
  • 集中式日誌管理
  • Platform-agnostic
  • 最小性能影響
  • 可自訂的輸出格式

適合對象

  • Dart 庫作者
  • 跨平台應用
  • 除錯工具
  • 即時監控系統
  • 開發人員使用的實用工具

使用建議

  • 需要應用層設定
  • 可能需要額外設定才能使用進階功能
  • 未針對高吞吐量生產日誌記錄進行優化
  • 有限的內建分析功能
  • 依賴外部設定檔案

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

An easy to use and extendable logging package for Dart. Especially useful for use in libraries, as it allows application to control logging from the imported libraries.

Console Printer Output

Features

  • Ability to filter logs from imported libraries
  • 100% configurable (print logs to console, write to file or send to backend all possible!)
  • Similar to other logging packages, so nothing new to learn

Usage

A simple usage example:

import 'package:quick_log/quick_log.dart';

void main() {
  const log = Logger('LogExample');

  log.debug('this is a debug message');
  log.info('this is an info message');
}

Configuring logger output:

import 'package:quick_log/quick_log.dart';

void main() {
  const log = Logger('LogExample');

  Logger.writer = ConsolePrinter(minLevel: LogLevel.info);

  log.d('this is a debug message');
  log.i('this is an info message');
}

Ignoring logs:

import 'package:quick_log/quick_log.dart';

class ExampleLogger extends Logger {
  const ExampleLogger(String name) : super(name, 'ExampleLogger');
}

void main() {
  const log = ExampleLogger('LogExample');

  Logger.writer = ConsolePrinter(onlyTags: []);
  // Or
  Logger.writer = ConsolePrinter(exceptTags: [log.name]);

  // These messages won't be printed
  log.d('this is a debug message');
  log.i('this is an info message');
}

Can be used in tests by using the LogStreamWriter:

import 'package:quick_log/quick_log.dart';

test('test', () {
  const log = Logger('LogExample');
  final writer = LogStreamWriter();
  Logger.writer = writer;

  log.i('this line was executed');
  
  expect(writer.pastMessages.length, 1);
  expect(writer.lastMessage.message, 'this is an info message');
});

Please file feature requests and bugs at the issue tracker.

所屬分類

依賴

依賴清單 3 項

原始碼儲存庫

使用此套件的專案