summaryrefslogtreecommitdiffstats
path: root/ui/ncurses/generic-main.c
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2014-04-04 13:05:18 +0800
committerJeremy Kerr <jk@ozlabs.org>2014-04-07 11:49:08 +0800
commitae3c354e844698bdb4ed35a6845aa9dca1e9205f (patch)
treeb741aa698f1b48d4bf3a42ac696cb1a6d6920465 /ui/ncurses/generic-main.c
parent3fa256bb478f2b3e6316c561169190457b21e616 (diff)
downloadtalos-petitboot-ae3c354e844698bdb4ed35a6845aa9dca1e9205f.tar.gz
talos-petitboot-ae3c354e844698bdb4ed35a6845aa9dca1e9205f.zip
log: Allow runtime selection of 'debug' log level
Currently, we need to compile with -DDEBUG to implement debug-level logging in the UIs and discover server. Since we may not be able to easily replace a system's petitboot binaries, this change introduces a -v|--verbose option to the discver server and ncurses UI, which enables debug at runtime. We also move some of the udev debug code out of an #ifdef DEBUG block. Since petitboot is generally started on boot, we also add a little infrastructure to pass -v to petitboot on certain system contitions: either petitboot.debug on the kernel command line, or a petitboot,debug? NVRAM property containing the value 'true'. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'ui/ncurses/generic-main.c')
-rw-r--r--ui/ncurses/generic-main.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/ui/ncurses/generic-main.c b/ui/ncurses/generic-main.c
index ad4c0cf..67b0b61 100644
--- a/ui/ncurses/generic-main.c
+++ b/ui/ncurses/generic-main.c
@@ -49,7 +49,7 @@ static void print_usage(void)
print_version();
printf(
"Usage: petitboot-nc [-h, --help] [-l, --log log-file]\n"
-" [-s, --start-daemon] [-V, --version]\n");
+" [-s, --start-daemon] [-v, --verbose] [-V, --version]\n");
}
/**
@@ -66,6 +66,7 @@ struct opts {
enum opt_value show_help;
const char *log_file;
enum opt_value start_daemon;
+ enum opt_value verbose;
enum opt_value show_version;
};
@@ -79,10 +80,11 @@ static int opts_parse(struct opts *opts, int argc, char *argv[])
{"help", no_argument, NULL, 'h'},
{"log", required_argument, NULL, 'l'},
{"start-daemon", no_argument, NULL, 's'},
+ {"verbose", no_argument, NULL, 'v'},
{"version", no_argument, NULL, 'V'},
{ NULL, 0, NULL, 0},
};
- static const char short_options[] = "dhl:sV";
+ static const char short_options[] = "dhl:svV";
static const struct opts default_values = { 0 };
*opts = default_values;
@@ -104,6 +106,9 @@ static int opts_parse(struct opts *opts, int argc, char *argv[])
case 's':
opts->start_daemon = opt_yes;
break;
+ case 'v':
+ opts->verbose = opt_yes;
+ break;
case 'V':
opts->show_version = opt_yes;
break;
@@ -297,6 +302,9 @@ int main(int argc, char *argv[])
pb_log_init(log);
+ if (opts.verbose)
+ pb_log_set_debug(true);
+
pb_log("--- petitboot-nc ---\n");
sa.sa_handler = sig_handler;
OpenPOWER on IntegriCloud