Commit 7a8d9e10 authored by Jan Včelák's avatar Jan Včelák 🚀

Merge 'knotd: debug level with -v flag'

parents 00e66824 2e15146b
...@@ -52,6 +52,9 @@ Use a remote control UNIX socket path (default is \fB@run_dir@/knot.sock\fP). ...@@ -52,6 +52,9 @@ Use a remote control UNIX socket path (default is \fB@run_dir@/knot.sock\fP).
Run the server as a daemon. New root directory may be specified Run the server as a daemon. New root directory may be specified
(default is \fB/\fP). (default is \fB/\fP).
.TP .TP
\fB\-v\fP, \fB\-\-verbose\fP
Enable debug output.
.TP
\fB\-h\fP, \fB\-\-help\fP \fB\-h\fP, \fB\-\-help\fP
Print the program help. Print the program help.
.TP .TP
......
...@@ -29,6 +29,9 @@ Parameters ...@@ -29,6 +29,9 @@ Parameters
Run the server as a daemon. New root directory may be specified Run the server as a daemon. New root directory may be specified
(default is :file:`/`). (default is :file:`/`).
**-v**, **--verbose**
Enable debug output.
**-h**, **--help** **-h**, **--help**
Print the program help. Print the program help.
......
...@@ -172,7 +172,7 @@ int log_init() ...@@ -172,7 +172,7 @@ int log_init()
/* Setup initial state. */ /* Setup initial state. */
int ret = KNOT_EOK; int ret = KNOT_EOK;
int emask = LOG_MASK(LOG_CRIT) | LOG_MASK(LOG_ERR) | LOG_MASK(LOG_WARNING); int emask = LOG_MASK(LOG_CRIT) | LOG_MASK(LOG_ERR) | LOG_MASK(LOG_WARNING);
int imask = LOG_MASK(LOG_NOTICE) | LOG_MASK(LOG_INFO) | LOG_MASK(LOG_DEBUG); int imask = LOG_MASK(LOG_NOTICE) | LOG_MASK(LOG_INFO);
/* Publish base log sink. */ /* Publish base log sink. */
struct log_sink *log = sink_setup(0); struct log_sink *log = sink_setup(0);
......
...@@ -275,6 +275,7 @@ static void print_help(void) ...@@ -275,6 +275,7 @@ static void print_help(void)
" -s, --socket <path> Use a remote control UNIX socket path.\n" " -s, --socket <path> Use a remote control UNIX socket path.\n"
" (default %s)\n" " (default %s)\n"
" -d, --daemonize=[dir] Run the server as a daemon (with new root directory).\n" " -d, --daemonize=[dir] Run the server as a daemon (with new root directory).\n"
" -v, --verbose Enable debug output.\n"
" -h, --help Print the program help.\n" " -h, --help Print the program help.\n"
" -V, --version Print the program version.\n", " -V, --version Print the program version.\n",
PROGRAM_NAME, CONF_DEFAULT_FILE, CONF_DEFAULT_DBDIR, RUN_DIR "/knot.sock"); PROGRAM_NAME, CONF_DEFAULT_FILE, CONF_DEFAULT_DBDIR, RUN_DIR "/knot.sock");
...@@ -352,6 +353,7 @@ int main(int argc, char **argv) ...@@ -352,6 +353,7 @@ int main(int argc, char **argv)
const char *confdb = NULL; const char *confdb = NULL;
const char *daemon_root = "/"; const char *daemon_root = "/";
char *socket = NULL; char *socket = NULL;
bool verbose = false;
/* Long options. */ /* Long options. */
struct option opts[] = { struct option opts[] = {
...@@ -359,6 +361,7 @@ int main(int argc, char **argv) ...@@ -359,6 +361,7 @@ int main(int argc, char **argv)
{ "confdb", required_argument, NULL, 'C' }, { "confdb", required_argument, NULL, 'C' },
{ "socket", required_argument, NULL, 's' }, { "socket", required_argument, NULL, 's' },
{ "daemonize", optional_argument, NULL, 'd' }, { "daemonize", optional_argument, NULL, 'd' },
{ "verbose", no_argument, NULL, 'v' },
{ "help", no_argument, NULL, 'h' }, { "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, 'V' }, { "version", no_argument, NULL, 'V' },
{ NULL } { NULL }
...@@ -366,7 +369,7 @@ int main(int argc, char **argv) ...@@ -366,7 +369,7 @@ int main(int argc, char **argv)
/* Parse command line arguments. */ /* Parse command line arguments. */
int opt = 0, li = 0; int opt = 0, li = 0;
while ((opt = getopt_long(argc, argv, "c:C:s:dhV", opts, &li)) != -1) { while ((opt = getopt_long(argc, argv, "c:C:s:dvhV", opts, &li)) != -1) {
switch (opt) { switch (opt) {
case 'c': case 'c':
config = optarg; config = optarg;
...@@ -383,6 +386,9 @@ int main(int argc, char **argv) ...@@ -383,6 +386,9 @@ int main(int argc, char **argv)
daemon_root = optarg; daemon_root = optarg;
} }
break; break;
case 'v':
verbose = true;
break;
case 'h': case 'h':
print_help(); print_help();
return EXIT_SUCCESS; return EXIT_SUCCESS;
...@@ -427,6 +433,9 @@ int main(int argc, char **argv) ...@@ -427,6 +433,9 @@ int main(int argc, char **argv)
/* Initialize logging subsystem. */ /* Initialize logging subsystem. */
log_init(); log_init();
if (verbose) {
log_levels_add(LOGT_STDOUT, LOG_ANY, LOG_MASK(LOG_DEBUG));
}
/* Set up the configuration */ /* Set up the configuration */
int ret = set_config(confdb, config); int ret = set_config(confdb, config);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment