diff --git a/sys/log/full/pkg.yml b/sys/log/full/pkg.yml index c8b8b0abfb..fe6f8c8b20 100644 --- a/sys/log/full/pkg.yml +++ b/sys/log/full/pkg.yml @@ -65,3 +65,6 @@ pkg.req_apis.LOG_STATS: pkg.init: log_init: 'MYNEWT_VAL(LOG_SYSINIT_STAGE_MAIN)' + +pkg.init.LOG_CLI_FILL_CMD: + shell_log_fill_register: $after:shell_init diff --git a/sys/log/full/src/log_shell.c b/sys/log/full/src/log_shell.c index 0f0036e166..a1d446c7e7 100644 --- a/sys/log/full/src/log_shell.c +++ b/sys/log/full/src/log_shell.c @@ -254,4 +254,45 @@ shell_log_storage_cmd(int argc, char **argv) } #endif +static int +log_fill_command(int argc, char **argv) +{ + const char *log_name; + struct log *log; + int num = 1; + + if (argc > 2) { + log_name = argv[2]; + log = log_find(log_name); + } else { + log = log_list_get_next(NULL); + } + if (log == NULL) { + console_printf("No log to fill\n"); + return -1; + } + if (argc > 1) { + num = atoi(argv[1]); + if (num <= 0 || num > 10000) { + num = 1; + } + } + + for (int i = 0; i < num; ++i) { + log_printf(log, MODLOG_MODULE_DFLT, LOG_LEVEL_INFO, "Log os_time %d", (int)os_time_get()); + } + + return 0; +} + +static struct shell_cmd log_fill_cmd = { + .sc_cmd = "log-fill", + .sc_cmd_func = log_fill_command +}; + +void +shell_log_fill_register(void) +{ + shell_cmd_register(&log_fill_cmd); +} #endif diff --git a/sys/log/full/syscfg.yml b/sys/log/full/syscfg.yml index 91709976f1..d48ae9703b 100644 --- a/sys/log/full/syscfg.yml +++ b/sys/log/full/syscfg.yml @@ -85,6 +85,10 @@ syscfg.defs: restrictions: - SHELL_TASK + LOG_CLI_FILL_CMD: + description: 'Add "log-fill" command for filling up log' + value: 0 + LOG_SHELL_SHOW_INDEX: description: '"log" command shows log index when dumping entries' value: 0