vxBoot/src/builtin/log.c

41 lines
1013 B
C

#include "vxBoot/builtin.h"
#include "vxBoot/terminal.h"
/* current log level */
extern int user_log_level;
/* log_help() : display help message */
static int log_help(void)
{
terminal_write(
"+---+-----------+---------------------+\n"
"|Lvl|Name |Description |\n"
"| 0 |LOG_EMERG |system is unusable |\n"
"| 1 |LOG_ALERT |action must be taken |\n"
"| 2 |LOG_CRIT |critical condition |\n"
"| 3 |LOG_ERR |error condition |\n"
"| 4 |LOG_WARNING|warning condition |\n"
"| 5 |LOG_NOTICE |significant condition|\n"
"| 6 |LOG_INFO |informational message|\n"
"| 7 |LOG_DEBUG |debug-level message |\n"
"\n"
"current level = %d\n",
user_log_level
);
return (0);
}
/* ls_main() : entry of the "ls" builtin */
int log_main(int argc, char **argv)
{
if (argc <= 1)
return (log_help());
if (argv[1][0] < '0' || argv[1][0] > '7') {
terminal_write("log: argument not recognized\n");
return (-1);
}
user_log_level = argv[1][0] - '0';
return (0);
}