diff options
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/pracrod.cc | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/server/src/pracrod.cc b/server/src/pracrod.cc index b8cbf13..e023bff 100644 --- a/server/src/pracrod.cc +++ b/server/src/pracrod.cc @@ -90,6 +90,7 @@ static const char usage_str[] = " -D, --debug ddd Enable debug messages on 'ddd'; see documentation for details\n" " -d --database db Use db as the database backend. Can be one of pgsql or testdb (default pgsql).\n" " -s, --ssl keyfile Enable ssl encryption with the key stored in keyfile.\n" +" -L, --logfile file Write output to file, instead of stderr.\n" ; ConfigurationParser *configparser = NULL; @@ -173,6 +174,7 @@ E0OPPYamkDI/+6Hx2KECQHF9xV1XatyXuFmfRAInK2BtfGY5UIvJaLxVD3Z1+i6q\n\ int main(int argc, char *argv[]) { + static FILE *logfp = stderr; int c; char *configfile = NULL; char *user = NULL; @@ -181,8 +183,7 @@ int main(int argc, char *argv[]) char *xml_basedir = NULL; char *debugstr = NULL; std::string database; - - debug_init(stderr); + std::string logfile; int option_index = 0; while(1) { @@ -198,10 +199,12 @@ int main(int argc, char *argv[]) {"debug", required_argument, 0, 'D'}, {"database", required_argument, 0, 'd'}, {"ssl", required_argument, 0, 's'}, + {"logfile", required_argument, 0, 'L'}, {0, 0, 0, 0} }; - c = getopt_long (argc, argv, "D:hvfc:u:g:x:d:s:", long_options, &option_index); + c = getopt_long (argc, argv, "D:hvfc:u:g:x:d:s:L:", + long_options, &option_index); if (c == -1) break; @@ -231,6 +234,10 @@ int main(int argc, char *argv[]) xml_basedir = strdup(optarg); break; + case 'L': + logfile = optarg; + break; + case 'D': debugstr = strdup(optarg); break; @@ -262,6 +269,15 @@ int main(int argc, char *argv[]) } } + if(logfile != "") { + logfp = fopen(logfile.c_str(), "a"); + if(!logfp) { + fprintf(stderr, "Could not write to logfile: '%s'\n", optarg); + logfp = stderr; + } + debug_init(logfp); + } + if(debugstr) { debug_parse(debugstr); } @@ -304,5 +320,7 @@ int main(int argc, char *argv[]) if(user) free(user); if(group) free(group); + if(logfp != stderr) fclose(logfp); + return 0; } |