Skip to content

Commit c6b2c9a

Browse files
committed
Add CvdMonitor command to monitor device logs.
This command repeatedly clears and prints the last 10 lines of launcher.log, kernel.log, and logcat in a bordered ASCII box. It includes unit tests for the display logic. Assisted-by: Jetski Bug: b/510094996
1 parent d48ed1b commit c6b2c9a

8 files changed

Lines changed: 499 additions & 31 deletions

File tree

base/cvd/cuttlefish/host/commands/cvd/cli/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ cf_cc_library(
9999
"//cuttlefish/host/commands/cvd/cli/commands:lint",
100100
"//cuttlefish/host/commands/cvd/cli/commands:login",
101101
"//cuttlefish/host/commands/cvd/cli/commands:logs",
102+
"//cuttlefish/host/commands/cvd/cli/commands:monitor",
102103
"//cuttlefish/host/commands/cvd/cli/commands:power_btn",
103104
"//cuttlefish/host/commands/cvd/cli/commands:powerwash",
104105
"//cuttlefish/host/commands/cvd/cli/commands:remove",

base/cvd/cuttlefish/host/commands/cvd/cli/commands/BUILD.bazel

Lines changed: 62 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("//cuttlefish/bazel:rules.bzl", "cf_cc_library")
1+
load("//cuttlefish/bazel:rules.bzl", "cf_cc_library", "cf_cc_test")
22

33
package(
44
default_visibility = ["//:android_cuttlefish"],
@@ -225,14 +225,35 @@ cf_cc_library(
225225
)
226226

227227
cf_cc_library(
228-
name = "power_btn",
229-
srcs = ["power_btn.cpp"],
230-
hdrs = ["power_btn.h"],
228+
name = "logs",
229+
srcs = ["logs.cpp"],
230+
hdrs = ["logs.h"],
231231
deps = [
232+
"//cuttlefish/common/libs/utils:files",
233+
"//cuttlefish/common/libs/utils:flag_parser",
232234
"//cuttlefish/host/commands/cvd/cli:command_request",
233235
"//cuttlefish/host/commands/cvd/cli:types",
234236
"//cuttlefish/host/commands/cvd/cli/commands:command_handler",
235237
"//cuttlefish/host/commands/cvd/cli/selector",
238+
"//cuttlefish/host/commands/cvd/instances:instance_manager",
239+
"//cuttlefish/result",
240+
"//libbase",
241+
"@abseil-cpp//absl/log",
242+
],
243+
)
244+
245+
cf_cc_library(
246+
name = "monitor",
247+
srcs = ["monitor.cpp"],
248+
hdrs = ["monitor.h"],
249+
deps = [
250+
"//cuttlefish/common/libs/fs",
251+
"//cuttlefish/common/libs/utils:flag_parser",
252+
"//cuttlefish/host/commands/cvd/cli:command_request",
253+
"//cuttlefish/host/commands/cvd/cli:types",
254+
"//cuttlefish/host/commands/cvd/cli:utils",
255+
"//cuttlefish/host/commands/cvd/cli/commands:command_handler",
256+
"//cuttlefish/host/commands/cvd/cli/selector",
236257
"//cuttlefish/host/commands/cvd/instances",
237258
"//cuttlefish/host/commands/cvd/instances:instance_manager",
238259
"//cuttlefish/result",
@@ -241,12 +262,22 @@ cf_cc_library(
241262
],
242263
)
243264

265+
cf_cc_test(
266+
name = "monitor_test",
267+
srcs = ["monitor_test.cpp"],
268+
deps = [
269+
":monitor",
270+
"//cuttlefish/common/libs/fs",
271+
"//cuttlefish/result:result_matchers",
272+
"@abseil-cpp//absl/strings",
273+
],
274+
)
275+
244276
cf_cc_library(
245-
name = "powerwash",
246-
srcs = ["powerwash.cpp"],
247-
hdrs = ["powerwash.h"],
277+
name = "power_btn",
278+
srcs = ["power_btn.cpp"],
279+
hdrs = ["power_btn.h"],
248280
deps = [
249-
"//cuttlefish/common/libs/utils:flag_parser",
250281
"//cuttlefish/host/commands/cvd/cli:command_request",
251282
"//cuttlefish/host/commands/cvd/cli:types",
252283
"//cuttlefish/host/commands/cvd/cli/commands:command_handler",
@@ -260,9 +291,9 @@ cf_cc_library(
260291
)
261292

262293
cf_cc_library(
263-
name = "screen_recording",
264-
srcs = ["screen_recording.cpp"],
265-
hdrs = ["screen_recording.h"],
294+
name = "powerwash",
295+
srcs = ["powerwash.cpp"],
296+
hdrs = ["powerwash.h"],
266297
deps = [
267298
"//cuttlefish/common/libs/utils:flag_parser",
268299
"//cuttlefish/host/commands/cvd/cli:command_request",
@@ -273,9 +304,7 @@ cf_cc_library(
273304
"//cuttlefish/host/commands/cvd/instances:instance_manager",
274305
"//cuttlefish/result",
275306
"//libbase",
276-
"@abseil-cpp//absl/log",
277307
"@fmt",
278-
"@jsoncpp",
279308
],
280309
)
281310

@@ -333,6 +362,26 @@ cf_cc_library(
333362
],
334363
)
335364

365+
cf_cc_library(
366+
name = "screen_recording",
367+
srcs = ["screen_recording.cpp"],
368+
hdrs = ["screen_recording.h"],
369+
deps = [
370+
"//cuttlefish/common/libs/utils:flag_parser",
371+
"//cuttlefish/host/commands/cvd/cli:command_request",
372+
"//cuttlefish/host/commands/cvd/cli:types",
373+
"//cuttlefish/host/commands/cvd/cli/commands:command_handler",
374+
"//cuttlefish/host/commands/cvd/cli/selector",
375+
"//cuttlefish/host/commands/cvd/instances",
376+
"//cuttlefish/host/commands/cvd/instances:instance_manager",
377+
"//cuttlefish/result",
378+
"//libbase",
379+
"@abseil-cpp//absl/log",
380+
"@fmt",
381+
"@jsoncpp",
382+
],
383+
)
384+
336385
cf_cc_library(
337386
name = "snapshot",
338387
srcs = ["snapshot.cpp"],
@@ -453,21 +502,3 @@ cf_cc_library(
453502
"@jsoncpp",
454503
],
455504
)
456-
457-
cf_cc_library(
458-
name = "logs",
459-
srcs = ["logs.cpp"],
460-
hdrs = ["logs.h"],
461-
deps = [
462-
"//cuttlefish/common/libs/utils:files",
463-
"//cuttlefish/common/libs/utils:flag_parser",
464-
"//cuttlefish/host/commands/cvd/cli:command_request",
465-
"//cuttlefish/host/commands/cvd/cli:types",
466-
"//cuttlefish/host/commands/cvd/cli/commands:command_handler",
467-
"//cuttlefish/host/commands/cvd/cli/selector",
468-
"//cuttlefish/host/commands/cvd/instances:instance_manager",
469-
"//cuttlefish/result",
470-
"//libbase",
471-
"@abseil-cpp//absl/log",
472-
],
473-
)

0 commit comments

Comments
 (0)