{"id":21748299,"url":"https://github.com/surfstudio/flutter-surf-logger","last_synced_at":"2025-04-13T07:13:12.696Z","repository":{"id":40369517,"uuid":"385149204","full_name":"surfstudio/flutter-surf-logger","owner":"surfstudio","description":"Made by Surf 🏄","archived":false,"fork":false,"pushed_at":"2024-04-17T15:30:06.000Z","size":542,"stargazers_count":12,"open_issues_count":0,"forks_count":0,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-04-13T07:13:07.397Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/surfstudio.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2021-07-12T06:39:56.000Z","updated_at":"2024-04-10T08:31:38.000Z","dependencies_parsed_at":"2024-04-15T07:02:33.940Z","dependency_job_id":null,"html_url":"https://github.com/surfstudio/flutter-surf-logger","commit_stats":{"total_commits":54,"total_committers":8,"mean_commits":6.75,"dds":0.6111111111111112,"last_synced_commit":"060f9c22f81ff64450f26fc9d0e517ba789794a8"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/surfstudio%2Fflutter-surf-logger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/surfstudio%2Fflutter-surf-logger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/surfstudio%2Fflutter-surf-logger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/surfstudio%2Fflutter-surf-logger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/surfstudio","download_url":"https://codeload.github.com/surfstudio/flutter-surf-logger/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248675422,"owners_count":21143768,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-26T08:12:57.226Z","updated_at":"2025-04-13T07:13:12.668Z","avatar_url":"https://github.com/surfstudio.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Surf Logger\n\n\u003cimg src=\"https://raw.githubusercontent.com/surfstudio/flutter-open-source/main/assets/logo_black.png#gh-light-mode-only\" width=\"200\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/surfstudio/flutter-open-source/main/assets/logo_white.png#gh-dark-mode-only\" width=\"200\"\u003e\n\nMade by [Surf 🏄‍♂️🏄‍♂️🏄‍♂️](https://surf.dev)\n\n[![Build Status](https://shields.io/github/actions/workflow/status/surfstudio/flutter-surf-logger/on_pull_request.yml?logo=github\u0026logoColor=white)](https://github.com/surfstudio/flutter-surf-logger)\n[![Coverage Status](https://img.shields.io/codecov/c/github/surfstudio/flutter-surf-logger?logo=codecov\u0026logoColor=white)](https://app.codecov.io/gh/surfstudio/flutter-surf-logger)\n[![Pub Version](https://img.shields.io/pub/v/surf_logger?logo=dart\u0026logoColor=white)](https://pub.dev/packages/surf_logger)\n[![Pub Likes](https://badgen.net/pub/likes/surf_logger)](https://pub.dev/packages/surf_logger)\n[![Pub popularity](https://badgen.net/pub/popularity/surf_logger)](https://pub.dev/packages/surf_logger/score)\n![Flutter Platform](https://badgen.net/pub/flutter-platform/surf_logger)\n\n## Overview\n\nSurf Logger is a utility that allows for quick and easy configuration of logging for a production-level application.\n\nThis library does not limit your use of third-party loggers. Instead, it provides a tool for configuring logging within your application.\n\n## Installation\n\nAdd `surf_logger` to your `pubspec.yaml` file:\n\n```yaml\ndependencies:\n  surf_logger: $currentVersion$\n```\n\n\u003cp\u003eAt this moment, the current version of \u003ccode\u003esurf_logger\u003c/code\u003e is \u003ca href=\"https://pub.dev/packages/surf_logger\"\u003e\u003cimg style=\"vertical-align:middle;\" src=\"https://img.shields.io/pub/v/surf_logger.svg\" alt=\"surf_logger version\"\u003e\u003c/a\u003e.\u003c/p\u003e\n\n## Example\n\n### Creating your own strategy\n\nYou can create your own logging strategy for different needs: logging to your own server, through Firebase, through Sentry, etc.\n\n```dart\nclass FirebaseLogStrategy implements LogStrategy {\n  final FirebaseCrashlytics _crashlytics;\n\n  CrashlyticsLogStrategy(this._crashlytics);\n\n  @override\n  void e(Exception exception, [StackTrace? stackTrace]) {\n    _crashlytics.recordError(exception, stackTrace);\n  }\n\n  @override\n  void log(Object message) {\n    _crashlytics.log('$message');\n    print('Message: $message');\n  }\n\n  @override\n  void w(String message, [Exception? exception]) {\n    _crashlytics.log('Warning: $message \\n Exception: $exception');\n  }\n}\n```\n\n### Choosing a strategy for the circumstances\n\nYou can configure the logger for the circumstances. For example, for the application flavor:\n\n```dart\nLogWriter setupLogger(Env env) {\n  return Logger.withStrategies({\n    if (env == Env.dev || env == Env.qa) ConsoleLogStrategy(),\n    if (env == Env.client || env == Env.qa) FileLogStrategy(),\n    if (env == Env.prod) ...[\n      FirebaseLogStrategy(),\n      SentryLogStrategy(),\n    ],\n  });\n}\n```\n\nPlease 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`.\n\nFor instance, the following methods will be available to an instance of `LogWriter`:\n\n```dart\nvoid main() {\n  final LogWriter logger = _setupLogger();\n  runApp(MyApp(logger: logger));\n  logger.log('message');\n  logger.e(Exception('exception'));\n  logger.w('message');\n}\n```\n\nAnd 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.\n\n```dart\nvoid main() {\n  final Logger logger = _setupLogger();\n  runApp(MyApp(logger: logger));\n  logger.log('message');\n  logger.contains(SomeLogStrategy());\n  logger.addStrategy(SomeLogStrategy());\n  logger.clearStrategies();\n  logger.e(Exception('exception'));\n  logger.w('message');\n}\n```\n\n## Migrating from 1.x.x to 2.x.x\n\n1.x.x\n\n```dart\nvoid setupLogger() {\n  RemoteLogger.addStrategy(CrashlyticsRemoteLogStrategy());\n  Logger.addStrategy(DebugLogStrategy());\n  Logger.addStrategy(RemoteLogStrategy());\n}\n```\n\nStarting from version 2.0.0, the logger is no longer a singleton. Now, you need to create an instance of the logger.\n`RemoteLogger` has been removed. Use `LogStrategy` to create any required strategy.\n\n```dart\nLogWriter setupLogger() {\n  return Logger.withStrategies({\n    CrashlyticsRemoteLogStrategy,\n    DebugLogStrategy,\n    RemoteLogStrategy(),\n  });\n}\n```\n\n## Changelog\n\nAll notable changes to this project will be documented in [this file](./CHANGELOG.md).\n\n## Issues\n\nTo report your issues, file directly in the [Issues](https://github.com/surfstudio/flutter-surf-logger/issues) section.\n\n## Contribute\n\nIf 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](./CONTRIBUTING.md) first and send us your pull request.\n\nYour PRs are always welcome.\n\n## How to reach us\n\nPlease feel free to ask any questions about this package. Join our community chat on Telegram. We speak English and Russian.\n\n[![Telegram](https://img.shields.io/badge/chat-on%20Telegram-blue.svg)](https://t.me/SurfGear)\n\n## License\n\n[Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsurfstudio%2Fflutter-surf-logger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsurfstudio%2Fflutter-surf-logger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsurfstudio%2Fflutter-surf-logger/lists"}