パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v2.0.2

surf_logger

Dart および Flutter 向けのプロダクションレベルのロガー

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
1170
いいね数
24
Pub ポイント
150

パッケージをインストール

flutter pub add surf_logger

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

surf_logger は、Dart および Flutter 向けの本番環境対応ログパッケージであり、複数のプラットフォームで構造的かつ信頼性が高く、設定可能なログ記録を提供することを目的としています。豊富なログフォーマット、フィルタリング、外部サービスとの統合をサポートしており、実世界のアプリケーションにおけるデバッグやモニタリングに最適です。このパッケージは surf.ru によってメンテナンスされており、pub.dev を通じてシームレスなセットアップが可能です。Android、iOS、Web、macOS、Windows、Linux のすべてに対応しており、デプロイ環境に関係なく一貫したログ記録動作を保証します。

用途

  • リアルタイムアプリデバッグ
  • 本番環境におけるエラーの追跡
  • パフォーマンス監視
  • 分析プラットフォームとの統合
  • 集中型ログ管理
  • クロスプラットフォームの一貫性

主な機能

  • 構造化ログ出力
  • 設定可能なログレベル
  • プラットフォームに依存しない設計
  • 拡張可能なフォーマッターサポート
  • 組み込みパフォーマンスメトリクス
  • カスタムログシンクのサポート

適している対象

  • プロダクショングレードの Flutter アプリ
  • 堅牢なログ記録を必要とするチーム
  • クロスプラットフォームログ記録が必要なアプリ
  • 観測性に焦点を当てる開発者
  • バックエンドログサービスと統合されるプロジェクト
  • 大規模アプリケーションの保守

注意事項

  • 最適な使用には設定が必要です
  • アプリのサイズがわずかに増加する可能性があります
  • 高度な機能には外部の依存関係に依存しています
  • パフォーマンスが重要なシナリオでは、ログのオーバーヘッドを監視する必要があります
  • 単純なデバッグ出力には向いていません
  • ログ集約ツールと併用するのが最適です

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

Surf Logger

Made by Surf 🏄‍♂️🏄‍♂️🏄‍♂️

Build Status Coverage Status Pub Version Pub Likes Pub popularity Flutter Platform

Overview

Surf Logger is a utility that allows for quick and easy configuration of logging for a production-level application.

This library does not limit your use of third-party loggers. Instead, it provides a tool for configuring logging within your application.

Installation

Add surf_logger to your pubspec.yaml file:

dependencies:
  surf_logger: $currentVersion$

At this moment, the current version of surf_logger is surf_logger version.

Example

Creating your own strategy

You can create your own logging strategy for different needs: logging to your own server, through Firebase, through Sentry, etc.

class FirebaseLogStrategy implements LogStrategy {
  final FirebaseCrashlytics _crashlytics;

  CrashlyticsLogStrategy(this._crashlytics);

  @override
  void e(Exception exception, [StackTrace? stackTrace]) {
    _crashlytics.recordError(exception, stackTrace);
  }

  @override
  void log(Object message) {
    _crashlytics.log('$message');
    print('Message: $message');
  }

  @override
  void w(String message, [Exception? exception]) {
    _crashlytics.log('Warning: $message \n Exception: $exception');
  }
}
Choosing a strategy for the circumstances

You can configure the logger for the circumstances. For example, for the application flavor:

LogWriter setupLogger(Env env) {
  return Logger.withStrategies({
    if (env == Env.dev || env == Env.qa) ConsoleLogStrategy(),
    if (env == Env.client || env == Env.qa) FileLogStrategy(),
    if (env == Env.prod) ...[
      FirebaseLogStrategy(),
      SentryLogStrategy(),
    ],
  });
}

Please note that Logger is a class for configuration, while LogWriter is for usage. This way, we provide access only to the necessary methods for logging, namely log, e, and w.

For instance, the following methods will be available to an instance of LogWriter:

void main() {
  final LogWriter logger = _setupLogger();
  runApp(MyApp(logger: logger));
  logger.log('message');
  logger.e(Exception('exception'));
  logger.w('message');
}

And an instance of Logger will have configuration management methods available. It's important to avoid using this class for other purposes, as it could potentially disrupt the configuration.

void main() {
  final Logger logger = _setupLogger();
  runApp(MyApp(logger: logger));
  logger.log('message');
  logger.contains(SomeLogStrategy());
  logger.addStrategy(SomeLogStrategy());
  logger.clearStrategies();
  logger.e(Exception('exception'));
  logger.w('message');
}

Migrating from 1.x.x to 2.x.x

1.x.x

void setupLogger() {
  RemoteLogger.addStrategy(CrashlyticsRemoteLogStrategy());
  Logger.addStrategy(DebugLogStrategy());
  Logger.addStrategy(RemoteLogStrategy());
}

Starting from version 2.0.0, the logger is no longer a singleton. Now, you need to create an instance of the logger. RemoteLogger has been removed. Use LogStrategy to create any required strategy.

LogWriter setupLogger() {
  return Logger.withStrategies({
    CrashlyticsRemoteLogStrategy,
    DebugLogStrategy,
    RemoteLogStrategy(),
  });
}

Changelog

All notable changes to this project will be documented in this file.

Issues

To report your issues, file directly in the Issues section.

Contribute

If you would like to contribute to the package (e.g. by improving the documentation, fixing a bug or adding a cool new feature), please read our contribution guide first and send us your pull request.

Your PRs are always welcome.

How to reach us

Please feel free to ask any questions about this package. Join our community chat on Telegram. We speak English and Russian.

Telegram

License

Apache License, Version 2.0

カテゴリー

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。