패키지, 저장소 및 앱 카테고리 검색

패키지 상세v2.0.2

surf_logger

Dart 및 Flutter용 프로덕션 레벨 로거

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
1.2천
좋아요
24
Pub 점수
150

패키지 설치

flutter pub add surf_logger

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

surf_logger는 Dart와 Flutter를 위한 프로덕션 준비 완료 로깅 패키지로, 다양한 플랫폼에서 구조화되고 신뢰할 수 있으며 구성 가능한 로깅을 제공하도록 설계되었습니다. 풍부한 로그 포맷팅, 필터링 및 외부 서비스와의 통합을 지원하여 실제 애플리케이션에서 디버깅과 모니터링에 이상적입니다. 이 패키지는 surf.ru에서 유지보수되며 pub.dev를 통해 손쉬운 설정이 가능합니다. Android, iOS, Web, macOS, Windows, Linux를 모두 지원하여 배포 환경에 관계없이 일관된 로깅 동작을 보장합니다.

사용 사례

  • 실시간 앱 디버깅
  • 생산 환경에서의 오류 추적
  • 성능 모니터링
  • 분석 플랫폼과의 통합
  • 중앙 집중식 로그 관리
  • 크로스 플랫폼 일관성

주요 기능

  • 구조화된 로그 출력
  • 사용자 정의 로그 레벨
  • 플랫폼 독립적 설계
  • 확장 가능한 포맷터 지원
  • 내장된 성능 메트릭
  • 사용자 정의 로그 싱크 지원

적합한 대상

  • 생산 수준의 플러터 앱
  • 강력한 로깅이 필요한 팀
  • 크로스 플랫폼 로깅이 필요한 앱
  • 관측성에 집중하는 개발자
  • 백엔드 로깅 서비스와 통합되는 프로젝트
  • 대규모 애플리케이션 유지보수

고려 사항

  • 최적의 사용을 위해 구성이 필요합니다
  • 앱 크기가 약간 증가할 수 있습니다
  • 고급 기능을 위해 외부 종속성에 의존합니다
  • 성능이 중요한 시나리오에서는 로깅 오버헤드를 모니터링해야 합니다
  • 간단한 디버그 출력용이 아님
  • 로그 집약 도구와 함께 사용하는 것이 가장 좋습니다

원본 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

카테고리

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.