Skip to content

Commit 11ef190

Browse files
committed
feat: able show log in shell
1 parent 79876ee commit 11ef190

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

README.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,26 @@ View android adb logcat logs in chrome devtools console
1919
DEVICE_SERIAL_xxxx device
2020
```
2121

22-
## Usage
22+
## Basic Usage
2323

2424
```shell
2525
npx logcat-in-devtools@latest
2626
```
2727

28-
### Options
28+
## Advanced Usage
29+
30+
```shell
31+
# Clean logcat buffer before start and also print logcat log in terminal
32+
npx logcat-in-devtools@latest --clean --show-log
33+
34+
# only print messages which include "aaa" or "bbb" or "ccc"
35+
npx logcat-in-devtools@latest --match="aaa\|bbb\|ccc" --show-log
36+
37+
# use device with given serial
38+
npx logcat-in-devtools@latest --serial DEVICE_SERIAL_xxxx
39+
```
40+
41+
### Cli options
2942

3043
```plaintext
3144
$ npx logcat-in-devtools@latest --help
@@ -37,6 +50,7 @@ View android adb logcat logs in chrome devtools console
3750
Options:
3851
-V, --version output the version number
3952
-c, --clean clean logcat buffer before start
53+
-l, --show-log also print logcat log in terminal
4054
-m, --match <RegExp> only print messages that match RegExp
4155
-s, --serial <SERIAL> use device with given serial (overrides $ANDROID_SERIAL)
4256
-h, --help display help for command

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "logcat-in-devtools",
3-
"version": "0.1.10",
3+
"version": "0.1.11",
44
"description": "View android adb logcat logs in chrome devtools console",
55
"homepage": "https://github.com/nieheyong/logcat-in-devtools.git",
66
"repository": {

src/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,18 @@ const packageJson = require("../package.json");
1818

1919
let logPattern: RegExp | null = null;
2020
let printDisable = false;
21+
let showLog = false;
2122

2223
function processAdbLogLine(log: string) {
2324
if (printDisable) return;
2425

2526
if (logPattern && !logPattern.test(log)) return;
2627
const [level, content] = styleLogcatLine(log);
2728
vmLog(level, content);
29+
30+
if (showLog) {
31+
stdWrite(content + "\n");
32+
}
2833
}
2934

3035
function togglePrint() {
@@ -135,16 +140,19 @@ interface CliOptions {
135140
clean: boolean;
136141
match: string;
137142
serial: string;
143+
showLog: boolean;
138144
}
139145

140146
program
141147
.option("-c, --clean", "clean logcat buffer before start")
148+
.option("-l, --show-log", "also print logcat log in terminal")
142149
.option("-m, --match <RegExp>", "only print messages that match RegExp")
143150
.option(
144151
"-s, --serial <SERIAL>",
145152
"use device with given serial (overrides $ANDROID_SERIAL)"
146153
)
147154
.action((options: CliOptions) => {
155+
showLog = options.showLog;
148156
run(options);
149157
})
150158
.parse();

0 commit comments

Comments
 (0)