vxBoot/src/builtin/log.c

50 lines
1.3 KiB
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(
"NAME\n"
" log - handle log level"
"\n"
"SYNOPSIS:\n"
" log [-h|--help|<log_leval>]\n"
"DESCRIPTION:\n"
" The log level define the importance of message sended througt the logger."
" There is a list of all supported log level with their importance:\n"
" +---+-----------+---------------------+\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';
terminal_write("current level = %d\n", user_log_level);
return (0);
}