{"id":13748320,"url":"https://github.com/openstf/adbkit-logcat","last_synced_at":"2025-05-09T10:32:27.408Z","repository":{"id":461882,"uuid":"14712264","full_name":"openstf/adbkit-logcat","owner":"openstf","description":"A Node.js interface for working with Android's logcat output.","archived":false,"fork":false,"pushed_at":"2022-05-26T08:56:42.000Z","size":89,"stargazers_count":44,"open_issues_count":2,"forks_count":29,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-04-22T17:58:52.271Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/openstf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-11-26T09:22:14.000Z","updated_at":"2025-04-14T09:07:23.000Z","dependencies_parsed_at":"2022-08-16T10:25:20.422Z","dependency_job_id":null,"html_url":"https://github.com/openstf/adbkit-logcat","commit_stats":null,"previous_names":["cyberagent/adbkit-logcat"],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openstf%2Fadbkit-logcat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openstf%2Fadbkit-logcat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openstf%2Fadbkit-logcat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openstf%2Fadbkit-logcat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/openstf","download_url":"https://codeload.github.com/openstf/adbkit-logcat/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253234178,"owners_count":21875561,"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-08-03T07:00:38.972Z","updated_at":"2025-05-09T10:32:24.037Z","avatar_url":"https://github.com/openstf.png","language":"JavaScript","funding_links":[],"categories":["CoffeeScript"],"sub_categories":[],"readme":"# adbkit-logcat\n\n# Warning\n\nThis repository was superseded by https://github.com/DeviceFarmer/adbkit-logcat\n\n# Warning\n\nThis repository was supreseded by https://github.com/DeviceFarmer/adbkit-logcat\n\n**adbkit-logcat** provides a [Node.js][nodejs] interface for working with output produced by the Android [`logcat` tool][logcat-site]. It takes a log stream (that you must create separately), parses it, and emits log entries in real-time as they occur. Possible use cases include storing logs in a database, forwarding logs via [MessagePack][msgpack], or just advanced filtering.\n\n## Requirements\n\n* [Node.js](http://nodejs.org/) 4.x or newer. Older versions are not supported.\n\n## Getting started\n\nInstall via NPM:\n\n```bash\nnpm install --save adbkit-logcat\n```\n\n### Examples\n\n#### Output all log messages\n\n##### JavaScript\n\n```javascript\nconst logcat = require('adbkit-logcat')\nconst {spawn} = require('child_process')\n\n// Retrieve a binary log stream\nconst proc = spawn('adb', ['logcat', '-B'])\n\n// Connect logcat to the stream\nreader = logcat.readStream(proc.stdout)\nreader.on('entry', entry =\u003e {\n  console.log(entry.message)\n})\n\n// Make sure we don't leave anything hanging\nprocess.on('exit', () =\u003e {\n  proc.kill()\n})\n```\n\n## API\n\n### Logcat\n\n#### logcat.Priority\n\nExposes `Priority`. See below for details.\n\n#### logcat.Reader\n\nExposes `Reader`. See below for details.\n\n#### logcat.readStream(stream[, options])\n\nCreates a logcat reader instance from the provided logcat event [`Stream`][node-stream]. Note that you must create the stream separately.\n\n**IMPORTANT: The default line break behavior has changed on newer Android versions. Since adbkit-logcat merely parses output and is not able to communicate with ADB, you must _externally_ detect whether you need the `fixLineFeeds` option enabled or not. For newer versions it should be off.**\n\n* **stream** The event stream to read.\n* **options** Optional. The following options are supported:\n    - **format** The format of the stream. Currently, the only supported value is `'binary'`, which (for example) `adb logcat -B` produces. Defaults to `'binary'`.\n    - **fixLineFeeds** On older Android versions, ADB shell automatically transformed any `'\\n'` into `'\\r\\n'`, which broke binary content. If set, this option reverses the transformation before parsing the stream. Defaults to `true` for backwards compatibility. You **MUST** set this option to `false` on newer versions.\n* Returns: The `Reader` instance.\n\n### Priority\n\n#### Constants\n\nThe following static properties are available:\n\n* **Priority.UNKNOWN** i.e. `0`.\n* **Priority.DEFAULT** i.e. `1`. Not available when reading a stream.\n* **Priority.VERBOSE** i.e. `2`.\n* **Priority.DEBUG** i.e. `3`.\n* **Priority.INFO** i.e. `4`.\n* **Priority.WARN** i.e. `5`.\n* **Priority.ERROR** i.e. `6`.\n* **Priority.FATAL** i.e. `7`.\n* **Priority.SILENT** i.e. `8`. Not available when reading a stream.\n\n#### Priority.fromLetter(letter)\n\nStatic method to convert the given `letter` into a numeric priority. For example, `Priority.fromName('d')` would return `Priority.DEBUG`.\n\n* **letter** The priority as a `String`. Any single, case-insensitive character matching the first character of any `Priority` constant is accepted.\n* Returns: The priority as a `Number`, or `undefined`.\n\n#### Priority.fromName(name)\n\nStatic method to convert the given `name` into a numeric priority. For example, `Priority.fromName('debug')` (or `Priority.fromName('d')`) would return `Priority.DEBUG`.\n\n* **name** The priority as a `String`. Any full, case-insensitive match of the `Priority` constants is accepted. If no match is found, falls back to `Priority.fromLetter()`.\n* Returns: The priority as a `Number`, or `undefined`.\n\n#### Priority.toLetter(priority)\n\nStatic method to convert the numeric priority into its letter representation. For example, `Priority.toLetter(Priority.DEBUG)` would return `'D'`.\n\n* **priority** The priority as a `Number`. Any `Priority` constant value is accepted.\n* Returns: The priority as a `String` letter, or `undefined`.\n\n#### Priority.toName(priority)\n\nStatic method to convert the numeric priority into its full string representation. For example, `Priority.toLetter(Priority.DEBUG)` would return `'DEBUG'`.\n\n* **priority** The priority as a `Number`. Any `Priority` constant value is accepted.\n* Returns: The priority as a `String`, or `undefined`.\n\n### Reader\n\nA reader instance, which is an [`EventEmitter`][node-events].\n\n#### Events\n\nThe following events are available:\n\n* **error** **(err)** Emitted when an error occurs.\n    * **err** An `Error`.\n* **end** Emitted when the stream ends.\n* **finish** Emitted when the stream finishes.\n* **entry** **(entry)** Emitted when the stream finishes.\n    * **entry** A log `Entry`. See below for details.\n\n#### constructor([options])\n\nFor advanced users. Manually constructs a `Reader` instance. Useful for testing and/or playing around. Normally you would use `logcat.readStream()` to create the instance.\n\n* **options** See `logcat.readStream()` for details.\n* Returns: N/A\n\n#### reader.connect(stream)\n\nFor advanced users. When instantiated manually (not via `logcat.readStream()`), connects the `Reader` instance to the given stream.\n\n* **stream** See `logcat.readStream()` for details.\n* Returns: The `Reader` instance.\n\n#### reader.end()\n\nConvenience method for ending the stream.\n\n* Returns: The `Reader` instance.\n\n#### reader.exclude(tag)\n\nSkip entries with the provided tag. Alias for `reader.include(tag, Priority.SILENT)`. Note that even skipped events have to be parsed so that they can be ignored.\n\n* **tag** The tag string to exclude. If `'*'`, works the same as `reader.excludeAll()`.\n* Returns: The `Reader` instance.\n\n#### reader.excludeAll()\n\nSkip **ALL** entries. Alias for `reader.includeAll(Priority.SILENT)`. Any entries you wish to see must be included via `include()`/`includeAll()`.\n\n* Returns: The `Reader` instance.\n\n#### reader.include(tag[, priority])\n\nInclude all entries with the given tag and a priority higher or equal to the given `priority`.\n\n* **tag** The tag string to include. If `'*'`, works the same as `reader.includeAll(priority)`.\n* **priority** Optional. A lower bound for the priority. Any numeric `Priority` constant or any `String` value accepted by `Priority.fromName()` is accepted. Defaults to `Priority.DEBUG`.\n* Returns: The `Reader` instance.\n\n#### reader.includeAll([priority])\n\nInclude all entries with a priority higher or equal to the given `priority`.\n\n* **tag** The tag string to exclude.\n* **priority** Optional. See `reader.include()` for details.\n* Returns: The `Reader` instance.\n\n#### reader.resetFilters()\n\nResets all inclusions/exclusions.\n\n* Returns: The `Reader` instance.\n\n### Entry\n\nA log entry.\n\n#### Properties\n\nThe following properties are available:\n\n* **date** Event time as a `Date`.\n* **pid** Process ID as a `Number`.\n* **tid** Thread ID as a `Number`.\n* **priority** Event priority as a `Number`. You can use `logcat.Priority` to convert the value into a `String`.\n* **tag** Event tag as a `String`.\n* **message** Message as a `String`.\n\n#### entry.toBinary()\n\nConverts the entry back to the binary log format.\n\n* Returns: The binary event as a [`Buffer`][node-buffer].\n\n## More information\n\n* [logprint.c](https://github.com/android/platform_system_core/blob/master/liblog/logprint.c)\n* [logcat.cpp](https://github.com/android/platform_system_core/blob/master/logcat/logcat.cpp)\n* [logger.h](https://github.com/android/platform_system_core/blob/master/include/log/logger.h)\n\n## Contributing\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md).\n\n## License\n\nSee [LICENSE](LICENSE).\n\nCopyright © The OpenSTF Project. All Rights Reserved.\n\n[nodejs]: \u003chttp://nodejs.org/\u003e\n[msgpack]: \u003chttp://msgpack.org/\u003e\n[logcat-site]: \u003chttp://developer.android.com/tools/help/logcat.html\u003e\n[node-stream]: \u003chttp://nodejs.org/api/stream.html\u003e\n[node-events]: \u003chttp://nodejs.org/api/events.html\u003e\n[node-buffer]: \u003chttp://nodejs.org/api/buffer.html\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenstf%2Fadbkit-logcat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopenstf%2Fadbkit-logcat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenstf%2Fadbkit-logcat/lists"}