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

套件詳情v5.0.1

l

跨平台的 html/io 日誌庫,擁有簡單的 API。可透過原生和 Web 控制台進行操作。支援 ASCII 顏色輸出。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
3220
喜歡數
93
Pub 分數
160

安裝套件

flutter pub add l

套件介紹

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

‘l’ 套件是適用於 Flutter 的跨平台記錄庫,為 Android、iOS、Web、macOS、Windows 和 Linux 提供簡單的 API 來記錄訊息。它支援透過原生與 Web 控制台進行輸出操作,並內建 ASCII 顏色化功能以提升日誌可讀性。非常適合即時除錯與監控應用程式行為,能無縫整合至開發工作流程中,且不會增加複雜度。此套件輕量級,專為需要一致、彩色且跨平台記錄的開發者設計。

適用情境

  • 跨平台即時除錯
  • 彩色控制台輸出,以提高日誌可見性
  • 開發和測試中的簡單整合
  • 跨平台日誌一致性
  • 在開發過程中監控應用程式行為
  • 同時調試網頁和移動應用

主要特色

  • 簡單直覺的 API
  • ASCII 顏色輸出
  • 支援所有主要的Flutter平台
  • 原生與網頁控制台相容性
  • 輕量且快速
  • 透過 flutter pub add 輕鬆設定

適合對象

  • Flutter 開發人員尋求簡單的記錄
  • 建構多平台應用的團隊
  • 專注於除錯效率的開發人員
  • 需要彩色控制台輸出的專案
  • 希望減少樣板代碼記錄日誌的使用者
  • 前端和後端除錯記錄

使用建議

  • 不適用於生產記錄
  • 顏色輸出可能無法在所有環境中呈現
  • 有限的設定選項
  • 最適合開發使用
  • 大型應用中可能需要額外的過濾
  • 取決於主控台的可用性

原始 README

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

[L]ogger

Pub Actions Status Coverage License: MIT Linter GitHub stars

About

Cross-platform html/io logger with simple API. No need to create a logger object. Just import and use. Simple and w/o boilerplate. Work with native console.

Core API

Example of usage

Example of using the library to display a message in the console.

Key features
Method Description
[s] A shout is always displayed
[v1], [v] Regular message with verbose level 1
[e] Error message with verbose level 1
[v2], [vv] Regular message with verbose level 2
[w] Warning message with verbose level 2
[v3], [vvv] Regular message with verbose level 3
[i], [<] Inform message with verbose level 3
[v4], [vvvv] Regular message with verbose level 4
[d], [<<] Debug message with verbose level 4
[v5], [vvvvv] Regular message with verbose level 5
[v6], [vvvvvv] Regular message with verbose level 6
l.s('shout me');
l.e('error msg');
l.w('warning msg');
l.i('info msg');
l < 'alt info msg';
l.d('debug msg');
l << 'alt debug msg';
l.v('verbose lvl #1');
l.vv('verbose lvl #2');
l.vvv('verbose lvl #3');
l.v4('verbose lvl #4');
l.v5('verbose lvl #5');
l.v6('verbose lvl #6');
Integration capabilities
Method Description
[listen] Broadcast stream receiving logs.
// Broadcast stream instantly receiving logs.
l.forEach((log) => print('* ${log.level} : ${log.message}'));
Print handling and customizing

Logger supports fine-tuning with the second argument LogOptions in a capture method. Also, you can handle print and output with l on some function or in a whole app with this simple syntax:

import 'package:l/l.dart';

void main() => l.capture(
      someFunction,
      const LogOptions(
        handlePrint: true,
        printColors: true,
        outputInRelease: false,
        messageFormatting: _messageFormatting,
      ),
    );

Future<void> someFunction() async {
  print('Hello');
  await Future<void>.delayed(const Duration(milliseconds: 150));
  l.d('world');
  await Future<void>.delayed(const Duration(milliseconds: 150));
  l.e('!!!');
}

Object _messageFormatting(Object message, LogLevel logLevel, DateTime now) =>
    '${now.hour}:${now.minute.toString().padLeft(2, '0')} $message';

Handling errors

Flutter
final sourceFlutterError = FlutterError.onError;
FlutterError.onError = (details) {
  l.w(details.exceptionAsString(), details.stack);
  sourceFlutterError?.call(details);
};
Crashlytics
l.where((msg) => msg.level.maybeWhen(
      error: () => true,
      warning: () => true,
      orElse: () => false,
    ))
  .map<String>((msg) => msg.message.toString())
  .listen(FirebaseCrashlytics.instance.log);
Zoned Errors
runZonedGuarded(someFunction, l.e);
Handling uncaught errors
Isolate.current
       ..setErrorsFatal(false)
       ..addErrorListener(
         RawReceivePort(
           (List<dynamic> pair) => // ignore: avoid_types_on_closure_parameters
               l.e(pair.first as Object),
         ).sendPort,
       );

Limitations

  • When there is no direct access to the terminal, it works through print.
  • !!! PLEASE, DO NOT LOG SENSITIVE INFORMATION !!!

Changelog

Refer to the Changelog to get all release notes.

Maintainers

Plague Fox

Funding

If you want to support the development of our library, there are several ways you can do it:

We appreciate any form of support, whether it's a financial donation or just a star on GitHub. It helps us to continue developing and improving our library. Thank you for your support!

License

MIT

所屬分類

依賴

依賴清單 1 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。