summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@anylike.org>2010-01-14 17:11:34 +0000
committerChristian Pointner <equinox@anylike.org>2010-01-14 17:11:34 +0000
commit87fca5597a82d1358add0fbfd62b2285563ab536 (patch)
treeba215e0479dd658065e5baac7ae23f107575c442
parentmoved default log target to options (diff)
added debug cmd line option
-rw-r--r--src/options.c10
-rw-r--r--src/options.h1
2 files changed, 11 insertions, 0 deletions
diff --git a/src/options.c b/src/options.c
index 8de7cc6..88d359f 100644
--- a/src/options.c
+++ b/src/options.c
@@ -184,10 +184,16 @@ int options_parse(options_t* opt, int argc, char* argv[])
PARSE_STRING_PARAM("-C","--chroot", opt->chroot_dir_)
PARSE_STRING_PARAM("-P","--write-pid", opt->pid_file_)
PARSE_STRING_LIST("-L","--log", opt->log_targets_)
+ PARSE_BOOL_PARAM("-U", "--debug", opt->debug_)
else
return i;
}
+ if(opt->debug_) {
+ string_list_add(&opt->log_targets_, "stdout:5");
+ opt->daemonize_ = 0;
+ }
+
if(!opt->log_targets_.first_) {
#ifndef WINVER
string_list_add(&opt->log_targets_, "syslog:3,anylike,daemon");
@@ -219,6 +225,7 @@ void options_default(options_t* opt)
opt->chroot_dir_ = NULL;
opt->pid_file_ = NULL;
string_list_init(&opt->log_targets_);
+ opt->debug_ = 0;
}
void options_lua_push_string(lua_State* L, const int tidx, const char* key, const char* value)
@@ -273,6 +280,7 @@ void options_lua_push(options_t* opt, lua_State* L)
options_lua_push_string(L, -3, "chroot_dir", opt->chroot_dir_);
options_lua_push_string(L, -3, "pid_file", opt->pid_file_);
options_lua_push_string_list(L, -3, &(opt->log_targets_));
+ options_lua_push_boolean(L, -3, "debug", opt->debug_);
}
void options_clear(options_t* opt)
@@ -305,6 +313,7 @@ void options_print_usage()
printf(" [-P|--write-pid] <path> write pid to this file\n");
printf(" [-L|--log] <target>:<level>[,<param1>[,<param2>..]]\n");
printf(" add a log target, can be invoked several times\n");
+ printf(" [-U|--debug] don't daemonize and log to stdout with maximum log level\n");
}
void options_print_version()
@@ -326,4 +335,5 @@ void options_print(options_t* opt)
printf("pid_file: '%s'\n", opt->pid_file_);
printf("log_targets: \n");
string_list_print(&opt->log_targets_, " '", "'\n");
+ printf("debug: %s\n", !opt->debug_ ? "false" : "true");
}
diff --git a/src/options.h b/src/options.h
index 7d1e74d..ef2daf3 100644
--- a/src/options.h
+++ b/src/options.h
@@ -45,6 +45,7 @@ struct options_struct {
char* chroot_dir_;
char* pid_file_;
string_list_t log_targets_;
+ int debug_;
};
typedef struct options_struct options_t;