-
Notifications
You must be signed in to change notification settings - Fork 0
/
log_test.c
52 lines (39 loc) · 1.18 KB
/
log_test.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <ctype.h>
#include <stddef.h>
#include <stdio.h>
#include <sys/queue.h>
#include "esp_console.h"
#include "esp_log.h"
#include "argtable3/argtable3.h"
static struct {
struct arg_str *tag;
struct arg_int *level;
struct arg_str *log;
struct arg_end *end;
} log_test_args;
static int cmd_log_test(int argc, char **argv)
{
int nerrors = arg_parse(argc, argv, (void **)&log_test_args);
if (nerrors != 0) {
arg_print_errors(stderr, log_test_args.end, argv[0]);
return 1;
}
ESP_LOG_LEVEL_LOCAL(log_test_args.level->ival[0],log_test_args.tag->sval[0], "%s", log_test_args.log->sval[0]);
return 0;
}
esp_err_t log_test_init(void)
{
log_test_args.tag = arg_str1(NULL, NULL, "log tag", "");
log_test_args.level = arg_int1(NULL, NULL, "log level", "");
log_test_args.log = arg_str1(NULL, NULL, "log message", "");
log_test_args.end = arg_end(3);
const esp_console_cmd_t log_test_cmd = {
.command = "log",
.help = "Print log",
.hint = NULL,
.func = &cmd_log_test,
.argtable = &log_test_args,
};
ESP_ERROR_CHECK(esp_console_cmd_register(&log_test_cmd));
return ESP_OK;
}