blob: abc523b497192cd84c41fea10ddbb575def68b5a [file] [log] [blame]
Simon Glassd5f61f22017-12-04 13:48:26 -07001/*
2 * Copyright (c) 2017 Google, Inc
3 * Written by Simon Glass <sjg@chromium.org>
4 *
5 * SPDX-License-Identifier: GPL-2.0+
6 */
7
8#include <common.h>
9#include <command.h>
10#include <dm.h>
11#include <log.h>
12
13static int do_log_level(cmd_tbl_t *cmdtp, int flag, int argc,
14 char * const argv[])
15{
16 if (argc > 1)
17 gd->default_log_level = simple_strtol(argv[1], NULL, 10);
18 else
19 printf("Default log level: %d\n", gd->default_log_level);
20
21 return 0;
22}
23
24static cmd_tbl_t log_sub[] = {
25 U_BOOT_CMD_MKENT(level, CONFIG_SYS_MAXARGS, 1, do_log_level, "", ""),
Simon Glassef11ed82017-12-04 13:48:27 -070026#ifdef CONFIG_LOG_TEST
27 U_BOOT_CMD_MKENT(test, 2, 1, do_log_test, "", ""),
28#endif
Simon Glassd5f61f22017-12-04 13:48:26 -070029};
30
31static int do_log(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
32{
33 cmd_tbl_t *cp;
34
35 if (argc < 2)
36 return CMD_RET_USAGE;
37
38 /* drop initial "log" arg */
39 argc--;
40 argv++;
41
42 cp = find_cmd_tbl(argv[0], log_sub, ARRAY_SIZE(log_sub));
43 if (cp)
44 return cp->cmd(cmdtp, flag, argc, argv);
45
46 return CMD_RET_USAGE;
47}
48
49#ifdef CONFIG_SYS_LONGHELP
50static char log_help_text[] =
51 "level - get/set log level\n"
Simon Glassef11ed82017-12-04 13:48:27 -070052#ifdef CONFIG_LOG_TEST
53 "log test - run log tests\n"
54#endif
Simon Glassd5f61f22017-12-04 13:48:26 -070055 ;
56#endif
57
58U_BOOT_CMD(
59 log, CONFIG_SYS_MAXARGS, 1, do_log,
60 "log system", log_help_text
61);