Lines Matching full:sh
17 typedef int (*log_backend_cmd_t)(const struct shell *sh,
59 static bool shell_state_precheck(const struct shell *sh) in shell_state_precheck() argument
61 if (sh->log_backend && in shell_state_precheck()
62 (sh->log_backend->control_block->state == SHELL_LOG_BACKEND_UNINIT)) { in shell_state_precheck()
63 shell_error(sh, "Shell log backend not initialized."); in shell_state_precheck()
73 static int shell_backend_cmd_execute(const struct shell *sh, in shell_backend_cmd_execute() argument
86 func(sh, NULL, argc, argv); in shell_backend_cmd_execute()
93 func(sh, backend, argc, argv); in shell_backend_cmd_execute()
95 shell_error(sh, "Invalid backend: %s", name); in shell_backend_cmd_execute()
103 static int log_status(const struct shell *sh, in log_status() argument
112 shell_warn(sh, "Logs are halted!"); in log_status()
115 shell_fprintf(sh, SHELL_NORMAL, "%-40s | current | built-in \r\n", in log_status()
117 shell_fprintf(sh, SHELL_NORMAL, in log_status()
129 shell_fprintf(sh, SHELL_NORMAL, "%-40s | %-7s | %s\r\n", in log_status()
138 static int cmd_log_self_status(const struct shell *sh, in cmd_log_self_status() argument
141 if (!shell_state_precheck(sh)) { in cmd_log_self_status()
145 return log_status(sh, sh->log_backend ? sh->log_backend->backend : NULL, argc, argv); in cmd_log_self_status()
148 static int cmd_log_backend_status(const struct shell *sh, in cmd_log_backend_status() argument
151 shell_backend_cmd_execute(sh, argc, argv, log_status); in cmd_log_backend_status()
171 static void filters_set(const struct shell *sh, in filters_set() argument
181 shell_warn(sh, "Backend not active."); in filters_set()
201 shell_warn(sh, "%s: level set to %s.", in filters_set()
205 shell_error(sh, "%s: unknown source name.", argv[i]); in filters_set()
222 static int log_enable(const struct shell *sh, in log_enable() argument
232 shell_error(sh, "Invalid severity: %s", argv[1]); in log_enable()
237 filters_set(sh, backend, argc - 2, &argv[2], severity_level); in log_enable()
241 static int cmd_log_self_enable(const struct shell *sh, in cmd_log_self_enable() argument
244 if (!shell_state_precheck(sh)) { in cmd_log_self_enable()
248 return log_enable(sh, sh->log_backend ? sh->log_backend->backend : NULL, argc, argv); in cmd_log_self_enable()
251 static int cmd_log_backend_enable(const struct shell *sh, in cmd_log_backend_enable() argument
254 return shell_backend_cmd_execute(sh, argc, argv, log_enable); in cmd_log_backend_enable()
257 static int log_disable(const struct shell *sh, in log_disable() argument
262 filters_set(sh, backend, argc - 1, &argv[1], LOG_LEVEL_NONE); in log_disable()
266 static int cmd_log_self_disable(const struct shell *sh, in cmd_log_self_disable() argument
269 if (!shell_state_precheck(sh)) { in cmd_log_self_disable()
273 return log_disable(sh, sh->log_backend ? sh->log_backend->backend : NULL, argc, argv); in cmd_log_self_disable()
276 static int cmd_log_backend_disable(const struct shell *sh, in cmd_log_backend_disable() argument
279 return shell_backend_cmd_execute(sh, argc, argv, log_disable); in cmd_log_backend_disable()
306 static int log_halt(const struct shell *sh, in log_halt() argument
316 shell_warn(sh, "Not supported for frontend"); in log_halt()
322 static int cmd_log_self_halt(const struct shell *sh, in cmd_log_self_halt() argument
325 if (!shell_state_precheck(sh)) { in cmd_log_self_halt()
329 return log_halt(sh, sh->log_backend ? sh->log_backend->backend : NULL, argc, argv); in cmd_log_self_halt()
332 static int cmd_log_backend_halt(const struct shell *sh, in cmd_log_backend_halt() argument
335 return shell_backend_cmd_execute(sh, argc, argv, log_halt); in cmd_log_backend_halt()
338 static int log_go(const struct shell *sh, in log_go() argument
348 shell_warn(sh, "Not supported for frontend"); in log_go()
354 static int cmd_log_self_go(const struct shell *sh, in cmd_log_self_go() argument
357 if (!shell_state_precheck(sh)) { in cmd_log_self_go()
361 return log_go(sh, sh->log_backend ? sh->log_backend->backend : NULL, argc, argv); in cmd_log_self_go()
364 static int cmd_log_backend_go(const struct shell *sh, in cmd_log_backend_go() argument
367 return shell_backend_cmd_execute(sh, argc, argv, log_go); in cmd_log_backend_go()
371 static int cmd_log_backends_list(const struct shell *sh, in cmd_log_backends_list() argument
375 shell_fprintf(sh, SHELL_NORMAL, in cmd_log_backends_list()
386 shell_print(sh, "%s", FRONTEND_STR); in cmd_log_backends_list()
392 static int cmd_log_mem(const struct shell *sh, size_t argc, char **argv) in cmd_log_mem() argument
401 shell_error(sh, "Failed to get usage (mode does not support it?)"); in cmd_log_mem()
405 shell_print(sh, "Log message buffer utilization report:"); in cmd_log_mem()
406 shell_print(sh, "\tCapacity: %u bytes", size); in cmd_log_mem()
407 shell_print(sh, "\tCurrently in use: %u bytes", used); in cmd_log_mem()
411 shell_print(sh, "Enable CONFIG_LOG_MEM_UTILIZATION to get maximum usage"); in cmd_log_mem()
415 shell_print(sh, "\tMaximum usage: %u bytes", max); in cmd_log_mem()