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).
Run the server as a daemon. New root directory may be specified
(default is \fB/\fP).
.TP
\fB\-v\fP, \fB\-\-verbose\fP
Enable debug output.
.TP
\fB\-h\fP, \fB\-\-help\fP
Print the program help.
.TP
......
......@@ -29,6 +29,9 @@ Parameters
Run the server as a daemon. New root directory may be specified
(default is :file:`/`).
**-v**, **--verbose**
Enable debug output.
**-h**, **--help**
Print the program help.
......
......@@ -172,7 +172,7 @@ int log_init()
/* Setup initial state. */
int ret = KNOT_EOK;
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. */
struct log_sink *log = sink_setup(0);
......
......@@ -275,6 +275,7 @@ static void print_help(void)
" -s, --socket <path> Use a remote control UNIX socket path.\n"
" (default %s)\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"
" -V, --version Print the program version.\n",
PROGRAM_NAME, CONF_DEFAULT_FILE, CONF_DEFAULT_DBDIR, RUN_DIR "/knot.sock");
......@@ -352,6 +353,7 @@ int main(int argc, char **argv)
const char *confdb = NULL;
const char *daemon_root = "/";
char *socket = NULL;
bool verbose = false;
/* Long options. */
struct option opts[] = {
......@@ -359,6 +361,7 @@ int main(int argc, char **argv)
{ "confdb", required_argument, NULL, 'C' },
{ "socket", required_argument, NULL, 's' },
{ "daemonize", optional_argument, NULL, 'd' },
{ "verbose", no_argument, NULL, 'v' },
{ "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, 'V' },
{ NULL }
......@@ -366,7 +369,7 @@ int main(int argc, char **argv)
/* Parse command line arguments. */
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) {
case 'c':
config = optarg;
......@@ -383,6 +386,9 @@ int main(int argc, char **argv)
daemon_root = optarg;
}
break;
case 'v':
verbose = true;
break;
case 'h':
print_help();
return EXIT_SUCCESS;
......@@ -427,6 +433,9 @@ int main(int argc, char **argv)
/* Initialize logging subsystem. */
log_init();
if (verbose) {
log_levels_add(LOGT_STDOUT, LOG_ANY, LOG_MASK(LOG_DEBUG));
}
/* Set up the configuration */
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