{"id":18352398,"url":"https://github.com/cleveroad/cr_logger","last_synced_at":"2025-04-06T11:32:54.770Z","repository":{"id":39993805,"uuid":"439350468","full_name":"Cleveroad/cr_logger","owner":"Cleveroad","description":null,"archived":false,"fork":false,"pushed_at":"2024-02-19T12:17:48.000Z","size":22923,"stargazers_count":17,"open_issues_count":3,"forks_count":24,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-21T22:22:29.658Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Cleveroad.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}},"created_at":"2021-12-17T13:56:46.000Z","updated_at":"2025-02-11T02:26:36.000Z","dependencies_parsed_at":"2024-02-19T13:50:21.204Z","dependency_job_id":null,"html_url":"https://github.com/Cleveroad/cr_logger","commit_stats":{"total_commits":23,"total_committers":2,"mean_commits":11.5,"dds":0.04347826086956519,"last_synced_commit":"a66b011665584bb4258e0ceee7b876e1d0198c2e"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cleveroad%2Fcr_logger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cleveroad%2Fcr_logger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cleveroad%2Fcr_logger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cleveroad%2Fcr_logger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Cleveroad","download_url":"https://codeload.github.com/Cleveroad/cr_logger/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247478152,"owners_count":20945258,"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-05T21:35:50.226Z","updated_at":"2025-04-06T11:32:49.761Z","avatar_url":"https://github.com/Cleveroad.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cr_logger\n\n\u003cimg src=\"https://raw.githubusercontent.com/Cleveroad/cr_logger/master/screenshots/plugin_banner.png\" width=\"100%\"\u003e\n\nWeb [example](https://cleveroad.github.io/cr_logger)\n\n**Flutter plugin for logging**\n\n* Simple logging to logcat.\n* Network request intercepting.\n* Log exporting (JSON format).\n* Proxy settings for \"Charles\".\n* Logs by level.\n\n**Supported Dart http client plugins:**  \n✔️ Dio  \n✔️ Chopper  \n✔️ Http from http/http package  \n✔️ HttpClient from dart:io package\n\n## Table of contents\n\n- [Screenshots](#screenshots)\n- [Getting Started](#getting-started)\n- [Usage](#usage)\n- [Quick actions](#quick-actions)\n- [Setup](#setup)\n\n## Screenshots\n\n\u003cimg src=\"https://raw.githubusercontent.com/Cleveroad/cr_logger/master/screenshots/http_log_screenshot.png\" height=\"500\"\u003e  \u003cimg src=\"https://raw.githubusercontent.com/Cleveroad/cr_logger/master/screenshots/debug_log_screenshot.png\" height=\"500\"\u003e  \u003cimg src=\"https://raw.githubusercontent.com/Cleveroad/cr_logger/master/screenshots/http_db_log_screenshot.png\" height=\"500\"\u003e\n\n\u003cimg src=\"https://raw.githubusercontent.com/Cleveroad/cr_logger/master/screenshots/quick_action_menu_screenshot.png\" height=\"500\"\u003e  \u003cimg src=\"https://raw.githubusercontent.com/Cleveroad/cr_logger/master/screenshots/http_request_screenshot.png\" height=\"500\"\u003e  \u003cimg src=\"https://raw.githubusercontent.com/Cleveroad/cr_logger/master/screenshots/http_response_screenshot.png\" height=\"500\"\u003e\n\n\u003cimg src=\"https://raw.githubusercontent.com/Cleveroad/cr_logger/master/screenshots/http_error_screenshot.png\" height=\"500\"\u003e  \u003cimg src=\"https://raw.githubusercontent.com/Cleveroad/cr_logger/master/screenshots/http_search_screenshot.png\" height=\"500\"\u003e  \u003cimg src=\"https://raw.githubusercontent.com/Cleveroad/cr_logger/master/screenshots/logs_search_screenshot.png\" height=\"500\"\u003e\n\n\u003cimg src=\"https://raw.githubusercontent.com/Cleveroad/cr_logger/master/screenshots/screenshot-web.png\" height=\"500\"\u003e\n\n## Getting Started\n\n1. Add plugin to the project:\n   ```yaml\n   dependencies:\n     cr_logger: ^2.2.0\n   ```\n\n2. Initialize the logger. main.dart:\n\n   ❗ Database won't be working in Web\n\n   ```dart\n   void main()  {\n     ...\n     CRLoggerInitializer.instance.init(\n       theme: ThemeData.light(),\n       levelColors: {\n         Level.debug: Colors.grey.shade300,\n         Level.warning: Colors.orange,\n       },\n       hiddenFields: [\n         'token',\n       ],\n       logFileName: 'my_logs',\n       printLogs: true,\n       useCrLoggerInReleaseBuild: false,\n       useDatabase: false,\n     );\n   }\n   ```\n   `printLogs` - Prints all logs while [printLogs] is true\n\n   `useCrLoggerInReleaseBuild` - All logs will be printed and used database when [kReleaseMode] is\n   true\n\n   `useDatabase` - Use database for logs history. Allows persisting logs on app restart. It will\n   work only with [useCrLoggerInReleaseBuild] set to true.\n\n   `theme` - Custom logger theme\n\n   `levelColors` - Colors for message types levelColors (debug, verbose, info, warning, error, wtf)\n\n   `hiddenFields` - List of keys, whose value need to be replaced by string 'Hidden'\n\n   `logFileName` - File name when sharing logs\n\n   `maxLogsCount` - Maximum number of each type of logs (http, debug, info, error), by default = 50\n\n   `maxDatabaseLogsCount` - Maximum number of each type of logs (http, debug, info, error), which\n   will be saved to database, by default = 50\n\n   `logger` - Custom logger\n\n   `printLogsCompactly` - If the value is false, then all logs, except HTTP logs, will have borders,\n   with a link to the place where the print is called and the time when the log was created.\n   Otherwise it will write only log message. By default = true\n\n3. Initialize Inspector (optional):\n\n   ```dart\n   return MaterialApp(\n     home: const MainPage(),\n     builder: (context, child) =\u003e CrInspector(child: child!),\n   );\n   ```\n\n4. Define the variables:\n\n   4.1 `appInfo` - you can provide custom information to be displayed on the AppInfo page\n   ```dart\n   CRLoggerInitializer.instance.appInfo = {\n     'Build type': buildType.toString(),\n     'Endpoint': 'https/cr_logger/example/',\n   };\n   ```\n\n   4.2 `logFileName` - file name when exporting logs\n\n   4.3 `hiddenFields` - list of keys for headers to hide when showing network logs\n\n5. Add the overlay button:\n\n   ```dart\n   CRLoggerInitializer.instance.showDebugButton(context);\n   ```\n\n   `button` - Custom floating button\n\n   `left` - X-axis start position\n\n   `top` - Y-axis start position\n\n6. Support for importing logs from json:\n\n   ```dart\n   await CRLoggerInitializer.instance.createLogsFromJson(json);\n   ```\n\n7. You can get the current proxy settings to initialise Charles:\n\n   ```dart\n   final proxy = CRLoggerInitializer.instance.getProxySettings();\n   if (proxy != null) {\n     RestClient.instance.init(proxy);\n   }\n   ```\n\n## Usage\n\nIf the logger is enabled, a floating button appears on the screen; it also indicates the project\nbuild number. It's quite easy to use, just click on the floating button to show the main screen of\nthe logger You can also `double tap` on the button to invoke **Quick Actions**.\n\n## Quick actions\n\nUsing this popup menu, you can **quickly access** the desired CRLogger options. Called by a **long\npress** or **double tap** on the debug button.\n\n#####\n\n#### App info\n\nAllows you to view **Package name**, **app version**, **build version**\n\n#### Clear logs\n\n**Clears** certain logs or all of them. It is possible to do this with logs from the database\n\n#### Show Inspector\n\nIf the **inspector** is enabled, then a panel appears on the right side of the screen, with buttons\nto toggle size inspection and the color picker.\n\n#### Set Charles proxy\n\nNeeded to set **proxy settings** for Charles\n\n#### Search\n\nProvides **search by logs**. By paths, you can search for **HTTP log** you need. Also there is a\nsearch for logs from the database.\n\n#### Share logs\n\nShare logs with your team\n\n#### Create log with parameter\n\nYou can create log with parameters. To do this use {{parameter}} pattern to highlight text needed to be displayed as parameter.\n\nExample:\n   ```dart\n     const parameter = 'PARAMETER';\n     log.d('Debug message with param: {{$parameter}}');\n     log.v('Verbose message with param: {{$parameter}}');\n     log.i('Info message with param: {{$parameter}}');\n     log.e('Error message with param: {{$parameter}}');\n   ```\nNow you can copy the value of this parameter by simply clicking on it in the details of the log.\n\n#### Actions and values\n\nOpens a page that contains action buttons and value notifiers.\n\n**Action buttons** allows you to add **different callbacks** for testing\n\n1. Add actions:\n\n   ```dart\n   CRLoggerInitializer.instance.addActionButton('Log Hi', () =\u003e log.i('Hi'));\n   CRLoggerInitializer.instance.addActionButton(\n     'Log By',\n     () =\u003e log.i('By'),\n     connectedWidgetId: 'some identifier',\n   );\n   ```\n\n2. Remove actions by specified id:\n\n   ```dart\n   CRLoggerInitializer.instance.removeActionsById('some identifier');\n   ```\n\n**Value notifiers** help keep track of changes to variables of **ValueNotifier** type.\n\n1. Type notifiers:\n\n   ```dart\n    /// Type notifiers\n     final boolNotifier = ValueNotifier\u003cbool\u003e(false);\n     final stringNotifier = ValueNotifier\u003cString\u003e('integer: ');\n\n    /// Widget notifiers\n    final boolWithWidgetNotifier = ValueNotifier\u003cbool\u003e(false);\n    final boolWidget = ValueListenableBuilder\u003cbool\u003e(\n      valueListenable: boolWithWidgetNotifier,\n      builder: (_, value, __) =\u003e SwitchListTile(\n        title: const Text('Bool'),\n        subtitle: Text(value.toString()),\n        value: value,\n        onChanged: (newValue) =\u003e boolWithWidgetNotifier.value = newValue,\n      ),\n    );\n     final textNotifier = ValueNotifier\u003cText\u003e(\n      const Text('Widget text'),\n     );\n     final textWidget = ValueListenableBuilder\u003cText\u003e(\n      valueListenable: textNotifier,\n      builder: (_, value, __) =\u003e Row(\n        children: [\n          const Text('Icon'),\n          const Spacer(),\n          value,\n          const Spacer(),\n        ],\n      ),\n    );\n   ```\n\n2. Add notifiers:\n   You can add either a `name` and a `notifier` or just a `widget`. If you just want to see the\n   value of the notifier, it's better to use `name` + `notifier`. In other case, if you need to\n   change notifier's value, for example via a switcher, it's better to add a `widget`.\n\n   ```dart\n    CRLoggerInitializer.instance.addValueNotifier(\n      widget: boolWidget,\n    );\n    \n    CRLoggerInitializer.instance.addValueNotifier(\n      name: 'Bool',\n      notifier: boolNotifier,\n    );\n    CRLoggerInitializer.instance.addValueNotifier(\n      widget: textWidget,\n    );\n   ```\n\n3. Remove notifiers by specified id:\n\n   ```dart\n   CRLoggerInitializer.instance.removeNotifiersById('some identifier');\n   ```\n\n4. Clear all notifiers:\n\n   ```dart\n   CRLoggerInitializer.instance.notifierListClear();\n   ```\n\n5. Initialize the following callbacks (optional):\n   5.1. `ShareLogsFileCallback` - when needed to share logs file on the app's side\n\n   ```dart\n   CRLoggerInitializer.instance.onShareLogsFile = (path) async {\n     await Share.shareFiles([path]);\n   };\n   ```\n\n#### App settings\n\nOpens application settings\n\n## Setup\n\nIn IntelliJ/Studio you can collapse the request/response body:\n\n![Gif showing collapsible body][show_body]\n\nSet up this is by going to `Preferences -\u003e Editor -\u003e General -\u003e Console`\nand under `Fold console lines that contain` add these 2 rules: `║`, `╟`\nand under `Exceptions` add 1 rule: `╔╣`\n\n![Settings][settings]\n\n[show_body]: https://raw.githubusercontent.com/Cleveroad/cr_logger/master/screenshots/http-logs-example.gif\n\n[settings]: https://raw.githubusercontent.com/Cleveroad/cr_logger/master/screenshots/settings-screenshot.png\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcleveroad%2Fcr_logger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcleveroad%2Fcr_logger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcleveroad%2Fcr_logger/lists"}