diff --git a/src/client.ts b/src/client.ts index 15910ab..a75766f 100644 --- a/src/client.ts +++ b/src/client.ts @@ -670,11 +670,6 @@ export class Client { * console.log(entry); * }); */ - public async openLogcat(serial: string): Promise; - public async openLogcat( - serial: string, - options: LogcatOptions - ): Promise; public async openLogcat( serial: string, options?: LogcatOptions @@ -686,6 +681,20 @@ export class Client { ).execute(); } + /** + * Opens logcat, uses TextParser instead of BinaryParser + * Allows filtering based on Priority @see `PriorityV2` @see `LogcatOptionsV2` + * Better performance that LogcatReader as filtering is done by ADB cli itself. + * @example + * import { Client, PriorityV2 } from 'adb-ts'; + * const adb = new Client(); + * const logcat = await adb.openLogcatV2('serial', { + * filterSpecs: { filters: [{ tag: 'ActivityManager', priority: PriorityV2 }] } + * }); + * for await (const entry of logcat.logs()) { + * console.log(entry); + * } + */ public async openLogcatV2( serial: string, options?: LogcatOptionsV2 diff --git a/src/device.ts b/src/device.ts index b9345f9..da9f054 100644 --- a/src/device.ts +++ b/src/device.ts @@ -22,13 +22,14 @@ import { PropertyValue, KeyEventOptions, InputDurationOptions, - NonEmptyArray + NonEmptyArray, + LogcatOptionsV2 } from './util'; import { Client } from './client'; import { Connection } from './connection'; import { FileStat } from './filestats'; import { KeyCode } from './util/keycode'; -import { LogcatReader } from './logcat/reader'; +import { LogcatReader, LogcatReaderV2 } from './logcat/reader'; import { Monkey } from './monkey/client'; import { PullTransfer } from './sync/pulltransfer'; import { PushTransfer } from './sync/pushtransfer'; @@ -128,7 +129,11 @@ export class Device implements IDevice { } public openLogcat(options?: LogcatOptions): Promise { - return this.client.openLogcat(this.id, options as LogcatOptions); + return this.client.openLogcat(this.id, options); + } + + public openLogcatV2(options?: LogcatOptionsV2): Promise { + return this.client.openLogcatV2(this.id, options); } public clear(pkg: string): Promise { diff --git a/src/linetransform.ts b/src/linetransform.ts index f04d5a5..62de1b4 100644 --- a/src/linetransform.ts +++ b/src/linetransform.ts @@ -1,6 +1,6 @@ import { Transform, TransformOptions } from 'stream'; -export interface LineTransformOptions extends TransformOptions { +interface LineTransformOptions extends TransformOptions { autoDetect: boolean; } /** diff --git a/src/logcat/index.ts b/src/logcat/index.ts index bc95689..3e0fd55 100644 --- a/src/logcat/index.ts +++ b/src/logcat/index.ts @@ -1,11 +1,6 @@ import { Writable } from 'stream'; import { LogcatReaderOptions } from '../util'; import { LogcatReader } from './reader'; - -export { - default as LineTransform, - LineTransformOptions -} from '../linetransform'; export * from './reader'; export * from './parser'; export * from './priority'; diff --git a/src/logcat/reader.ts b/src/logcat/reader.ts index 5dc6878..d04e339 100644 --- a/src/logcat/reader.ts +++ b/src/logcat/reader.ts @@ -70,6 +70,9 @@ export class LogcatReader extends StreamHandler { } } +/** + * @ignore + */ export interface TextParserConstruct { new (): TextParserBase; }