{"id":32292328,"url":"https://github.com/nesquikm/the_logger","last_synced_at":"2026-02-28T14:31:48.255Z","repository":{"id":219770183,"uuid":"749765895","full_name":"nesquikm/the_logger","owner":"nesquikm","description":"A modular logging library for Flutter.","archived":false,"fork":false,"pushed_at":"2025-10-21T04:13:43.000Z","size":773,"stargazers_count":5,"open_issues_count":8,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-23T03:30:32.112Z","etag":null,"topics":["flutter","logging","package"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/the_logger","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nesquikm.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"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,"publiccode":null,"codemeta":null}},"created_at":"2024-01-29T10:58:33.000Z","updated_at":"2025-02-11T12:43:42.000Z","dependencies_parsed_at":"2024-09-12T18:25:53.474Z","dependency_job_id":null,"html_url":"https://github.com/nesquikm/the_logger","commit_stats":null,"previous_names":["nesquikm/the_logger"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nesquikm/the_logger","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nesquikm%2Fthe_logger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nesquikm%2Fthe_logger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nesquikm%2Fthe_logger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nesquikm%2Fthe_logger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nesquikm","download_url":"https://codeload.github.com/nesquikm/the_logger/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nesquikm%2Fthe_logger/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29937391,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-28T13:49:17.081Z","status":"ssl_error","status_checked_at":"2026-02-28T13:48:50.396Z","response_time":90,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["flutter","logging","package"],"created_at":"2025-10-23T03:18:11.757Z","updated_at":"2026-02-28T14:31:48.179Z","avatar_url":"https://github.com/nesquikm.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TheLogger\n\n[![Analyze and test all][analyze_and_test_badge]][analyze_and_test_link]\n[![coverage][coverage_badge]][coverage_link]\n[![style: very good analysis][very_good_analysis_badge]][very_good_analysis_link]\n\nA modular logging library for Flutter.\n\n## Features\n\n\u003cimg src=\"https://github.com/nesquikm/the_logger/raw/main/images/colorful_logging.png\" width=\"300\" alt=\"Colorful logging\" align=\"right\"\u003e\n\n- Colorful console logging\n- Database logging\n- Custom logging\n- Sessions\n- Exports logs to compressed file\n- Flexible logs filtering and retaining strategies\n- Ability to mask sensitive data\n- Custom color scheme for console logging\n- Parsing and pretty printing JSON strings in logs\n\n## Getting started\n\nTo use this package, add `the_logger` and `logging` as a [dependency in your pubspec.yaml file](https://flutter.dev/docs/development/packages-and-plugins/using-packages).\n\n## Usage\n\nImport the packages:\n\n```dart\nimport 'package:the_logger/the_logger.dart';\nimport 'package:logging/logging.dart';\n```\n\nGet an instance of the logger and initialize it:\n\n```dart\nawait TheLogger.i().init();\n```\n\nAnd then you can use it by calling [Logger](https://pub.dev/packages/logging) methods:\n\n```dart\nfinal _log = Logger('MyHomePage');\n_log.finest('some finest log');\n```\n\nTheLogger is a singleton, so you can get the same instance anywhere in your app:\n\n```dart\nfinal instance = TheLogger.i();\n```\n\nThis should be done as early as possible in your app, and only once. Before calling `init()` second time, you should call `dispose()` method.\n\nYou can define retain strategy for logs. For example:\n\n```dart\nTheLogger.i().init(retainStrategy: {\n  Level.ALL:      200,  // ALL records will be deleted after 200 sessions\n  Level.INFO:     100,  // records with INFO and higher level retained for 300 sessions\n  Level.SEVERE:   50,   // records with SEVERE and higher level retained for 350 sessions\n});\n```\n\nLogs are separated by sessions. By default, TheLogger starts a new session every time you call `init()` method (but you can change this behavior by passing `startNewSession: false` to `init()` method):\n\n```dart\nTheLogger.i().init(startNewSession: false);\n```\n\nYou can start a new session manually by calling:\n\n```dart\nTheLogger.i().startSession();\n```\n\n`startSession()` can be called multiple times, for example when app resumes from background (see example).\n\nThere is a way to append session start log message with custom string (for example, you can add application version) or change session start log message level:\n\n```dart\nTheLogger.i().init(\n  sessionStartExtra: $appVersion,\n  sessionStartLevel: Level.FINE, // default is Level.INFO\n);\n```\n\nTo enable or disable console logging and whether to store logs in database, use:\n\n```dart\nTheLogger.i().init(\n  consoleLogger: false,\n  dbLogger: false,\n);\n```\n\nThere is a way to capture logs that will be sent to console by providing callback function `consoleLoggerCallback`:\n\n```dart\nTheLogger.i().init(\n  consoleLoggerCallback: (\n      String message, {\n      DateTime? time,\n      int? sequenceNumber,\n      int level = 0,\n      String name = '',\n      Zone? zone,\n      Object? error,\n      StackTrace? stackTrace,\n  ) {\n    // do something with the record\n  },\n);\n```\n\nYou can define custom color scheme for console logging by extending `ConsoleColors` class and providing it's instance to `init()` method as `consoleColors` parameter.\n\nConsole logger tries to parse embedded in `message` and `error` JSON strings and print them in pretty format. You can disable this feature by setting `consoleFormatJson` to `false` in `init()` method.\n\nYou can add custom loggers (for example for sending logs to server):\n\n```dart\nTheLogger.i().init(\n  customLoggers: [\n    remoteLogger,\n    anotherLogger,\n  ],\n);\n```\n\nTo write all logs to compressed file call `writeAllLogsToJson` method:\n\n```dart\nfinal filePath = await TheLogger.i().writeAllLogsToJson();\n```\n\nThis method returns a path to the file with logs. You can send this file to server, ask user to send it to you, or do whatever you want with it.\n\nFor debugging purposes, you can get all logs from database and clear all logs from database:\n\n```dart\nfinal logsAsString = await TheLogger.i().getAllLogsAsString();\nfinal logsAsList = await TheLogger.i().getAllLogs();\nfinal logsAsMaps = await TheLogger.i().getAllLogsAsMaps();\nfinal logsAsMaps = await TheLogger.i().clearAllLogs();\n```\n\nTo mask sensitive data in logs, you can provide a list of strings or regular expressions:\n\n```dart\nTheLogger.i().addMaskingString(MaskingString('password'));\nTheLogger.i().addMaskingStrings(\n  {\n    MaskingString(\n      's[ecr]+t',\n      isRegExp: true,\n    ),\n    MaskingString(\n      'seed',\n      caseSensitive: false,\n      maskedString: '######',\n    ),\n  },\n);\n```\n\n## Viewing logs\n\nYou can view logs in console while debugging your app. Also you can add sending logs to server by adding custom logger or by using `writeAllLogsToJson` method, which writes all logs to compressed file that you can send by email or 'share' it in any other way. To view exported logs, you can use [TheLoggerViewer](https://nesquikm.github.io/the_logger_viewer).\n\n## Testing\n\nThis package includes several unit tests for its features. To run the tests, use the following command:\n\n```bash\nflutter test\n```\n\n[analyze_and_test_badge]: https://github.com/nesquikm/the_logger/actions/workflows/analyze-and-test.yaml/badge.svg\n[analyze_and_test_link]: https://github.com/nesquikm/the_logger/actions/workflows/analyze-and-test.yaml\n[coverage_badge]: https://nesquikm.github.io/the_logger/coverage_badge.svg\n[coverage_link]: https://nesquikm.github.io/the_logger/html\n[very_good_analysis_badge]: https://img.shields.io/badge/style-very_good_analysis-B22C89.svg\n[very_good_analysis_link]: https://pub.dev/packages/very_good_analysis\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnesquikm%2Fthe_logger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnesquikm%2Fthe_logger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnesquikm%2Fthe_logger/lists"}