$ cnpm install adbkit-logcat
adbkit-logcat provides a Node.js interface for working with output produced by the Android logcat tool. 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, or just advanced filtering.
Install via NPM:
npm install --save adbkit-logcat
const logcat = require('adbkit-logcat')
const {spawn} = require('child_process')
// Retrieve a binary log stream
const proc = spawn('adb', ['logcat', '-B'])
// Connect logcat to the stream
reader = logcat.readStream(proc.stdout)
reader.on('entry', entry => {
console.log(entry.message)
})
// Make sure we don't leave anything hanging
process.on('exit', () => {
proc.kill()
})
Exposes Priority. See below for details.
Exposes Reader. See below for details.
Creates a logcat reader instance from the provided logcat event Stream. Note that you must create the stream separately.
'binary', which (for example) adb logcat -B produces. Defaults to 'binary'.'\n' in the output to '\r\n', which breaks binary content. If set, this option reverses the transformation before parsing the stream. Defaults to true.Reader instance.The following static properties are available:
0.1. Not available when reading a stream.2.3.4.5.6.7.8. Not available when reading a stream.Static method to convert the given letter into a numeric priority. For example, Priority.fromName('d') would return Priority.DEBUG.
String. Any single, case-insensitive character matching the first character of any Priority constant is accepted.Number, or undefined.Static method to convert the given name into a numeric priority. For example, Priority.fromName('debug') (or Priority.fromName('d')) would return Priority.DEBUG.
String. Any full, case-insensitive match of the Priority constants is accepted. If no match is found, falls back to Priority.fromLetter().Number, or undefined.Static method to convert the numeric priority into its letter representation. For example, Priority.toLetter(Priority.DEBUG) would return 'D'.
Number. Any Priority constant value is accepted.String letter, or undefined.Static method to convert the numeric priority into its full string representation. For example, Priority.toLetter(Priority.DEBUG) would return 'DEBUG'.
Number. Any Priority constant value is accepted.String, or undefined.A reader instance, which is an EventEmitter.
The following events are available:
Error.Entry. See below for details.For advanced users. Manually constructs a Reader instance. Useful for testing and/or playing around. Normally you would use logcat.readStream() to create the instance.
logcat.readStream() for details.For advanced users. When instantiated manually (not via logcat.readStream()), connects the Reader instance to the given stream.
logcat.readStream() for details.Reader instance.Convenience method for ending the stream.
Reader instance.Skip 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.
'*', works the same as reader.excludeAll().Reader instance.Skip ALL entries. Alias for reader.includeAll(Priority.SILENT). Any entries you wish to see must be included via include()/includeAll().
Reader instance.Include all entries with the given tag and a priority higher or equal to the given priority.
'*', works the same as reader.includeAll(priority).Priority constant or any String value accepted by Priority.fromName() is accepted. Defaults to Priority.DEBUG.Reader instance.Include all entries with a priority higher or equal to the given priority.
reader.include() for details.Reader instance.Resets all inclusions/exclusions.
Reader instance.A log entry.
The following properties are available:
Date.Number.Number.Number. You can use logcat.Priority to convert the value into a String.String.String.Converts the entry back to the binary log format.
Buffer.See CONTRIBUTING.md.
See LICENSE.
Copyright © The OpenSTF Project. All Rights Reserved.
Copyright 2013 - present © cnpmjs.org | Home |