default log level to LOG_WARN

write message to stderr if -D flag out of range
This commit is contained in:
onyx-and-iris 2024-06-27 01:17:59 +01:00
parent 4488a386b8
commit 0b6e0800ce

View File

@ -42,10 +42,10 @@ int main(int argc, char *argv[])
if (argc == 1)
{
help();
return EXIT_SUCCESS;
exit(EXIT_SUCCESS);
}
log_set_level(LOG_INFO);
log_set_level(LOG_WARN);
while ((opt = getopt(argc, argv, "k:ihD:")) != -1)
{
@ -62,10 +62,18 @@ int main(int argc, char *argv[])
help();
exit(EXIT_SUCCESS);
case 'D':
if ((dvalue = atoi(optarg)) && dvalue >= LOG_TRACE && dvalue <= LOG_FATAL)
dvalue = atoi(optarg);
if (dvalue >= LOG_TRACE && dvalue <= LOG_FATAL)
{
log_set_level(dvalue);
}
else
{
fputs(
"-D arg out of range, expected value from 0 up to 5\n"
"Log level will default to LOG_WARN (3).\n",
stderr);
}
break;
default:
abort();
@ -224,7 +232,7 @@ void parse_command(T_VBVMR_INTERFACE *vmr, char *command)
puts(res.val.s);
break;
default:
fputs("Unknown result...", stderr);
fputs("Unexpected result type", stderr);
break;
}
}