|
|
@@ -33,7 +33,6 @@
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
#include <misc/version.h>
|
|
|
-#include <misc/loggers_string.h>
|
|
|
#include <misc/loglevel.h>
|
|
|
#include <misc/offset.h>
|
|
|
#include <misc/read_file.h>
|
|
|
@@ -46,6 +45,7 @@
|
|
|
#include <structure/LinkedList1.h>
|
|
|
#include <structure/LinkedList2.h>
|
|
|
#include <base/BLog.h>
|
|
|
+#include <base/BLog_syslog.h>
|
|
|
#include <system/BReactor.h>
|
|
|
#include <system/BSignal.h>
|
|
|
#include <system/BConnection.h>
|
|
|
@@ -56,16 +56,13 @@
|
|
|
#include <ncd/NCDModuleIndex.h>
|
|
|
#include <ncd/modules/modules.h>
|
|
|
|
|
|
-#ifndef BADVPN_USE_WINAPI
|
|
|
-#include <base/BLog_syslog.h>
|
|
|
-#endif
|
|
|
-
|
|
|
#include <ncd/ncd.h>
|
|
|
|
|
|
#include <generated/blog_channel_ncd.h>
|
|
|
|
|
|
#define LOGGER_STDOUT 1
|
|
|
-#define LOGGER_SYSLOG 2
|
|
|
+#define LOGGER_STDERR 2
|
|
|
+#define LOGGER_SYSLOG 3
|
|
|
|
|
|
#define ARG_VALUE_TYPE_STRING 1
|
|
|
#define ARG_VALUE_TYPE_VARIABLE 2
|
|
|
@@ -144,10 +141,8 @@ struct {
|
|
|
int help;
|
|
|
int version;
|
|
|
int logger;
|
|
|
- #ifndef BADVPN_USE_WINAPI
|
|
|
char *logger_syslog_facility;
|
|
|
char *logger_syslog_ident;
|
|
|
- #endif
|
|
|
int loglevel;
|
|
|
int loglevels[BLOG_NUM_CHANNELS];
|
|
|
char *config_file;
|
|
|
@@ -266,14 +261,15 @@ int main (int argc, char **argv)
|
|
|
case LOGGER_STDOUT:
|
|
|
BLog_InitStdout();
|
|
|
break;
|
|
|
- #ifndef BADVPN_USE_WINAPI
|
|
|
+ case LOGGER_STDERR:
|
|
|
+ BLog_InitStderr();
|
|
|
+ break;
|
|
|
case LOGGER_SYSLOG:
|
|
|
if (!BLog_InitSyslog(options.logger_syslog_ident, options.logger_syslog_facility)) {
|
|
|
fprintf(stderr, "Failed to initialize syslog logger\n");
|
|
|
goto fail0;
|
|
|
}
|
|
|
break;
|
|
|
- #endif
|
|
|
default:
|
|
|
ASSERT(0);
|
|
|
}
|
|
|
@@ -441,13 +437,11 @@ void print_help (const char *name)
|
|
|
" %s\n"
|
|
|
" [--help]\n"
|
|
|
" [--version]\n"
|
|
|
- " [--logger <"LOGGERS_STRING">]\n"
|
|
|
- #ifndef BADVPN_USE_WINAPI
|
|
|
+ " [--logger <stdout/stderr/syslog>]\n"
|
|
|
" (logger=syslog?\n"
|
|
|
" [--syslog-facility <string>]\n"
|
|
|
" [--syslog-ident <string>]\n"
|
|
|
" )\n"
|
|
|
- #endif
|
|
|
" [--loglevel <0-5/none/error/warning/notice/info/debug>]\n"
|
|
|
" [--channel-loglevel <channel-name> <0-5/none/error/warning/notice/info/debug>] ...\n"
|
|
|
" --config-file <file>\n"
|
|
|
@@ -471,11 +465,9 @@ int parse_arguments (int argc, char *argv[])
|
|
|
|
|
|
options.help = 0;
|
|
|
options.version = 0;
|
|
|
- options.logger = LOGGER_STDOUT;
|
|
|
- #ifndef BADVPN_USE_WINAPI
|
|
|
+ options.logger = LOGGER_STDERR;
|
|
|
options.logger_syslog_facility = "daemon";
|
|
|
options.logger_syslog_ident = argv[0];
|
|
|
- #endif
|
|
|
options.loglevel = -1;
|
|
|
for (int i = 0; i < BLOG_NUM_CHANNELS; i++) {
|
|
|
options.loglevels[i] = -1;
|
|
|
@@ -503,18 +495,18 @@ int parse_arguments (int argc, char *argv[])
|
|
|
if (!strcmp(arg2, "stdout")) {
|
|
|
options.logger = LOGGER_STDOUT;
|
|
|
}
|
|
|
- #ifndef BADVPN_USE_WINAPI
|
|
|
+ else if (!strcmp(arg2, "stderr")) {
|
|
|
+ options.logger = LOGGER_STDERR;
|
|
|
+ }
|
|
|
else if (!strcmp(arg2, "syslog")) {
|
|
|
options.logger = LOGGER_SYSLOG;
|
|
|
}
|
|
|
- #endif
|
|
|
else {
|
|
|
fprintf(stderr, "%s: wrong argument\n", arg);
|
|
|
return 0;
|
|
|
}
|
|
|
i++;
|
|
|
}
|
|
|
- #ifndef BADVPN_USE_WINAPI
|
|
|
else if (!strcmp(arg, "--syslog-facility")) {
|
|
|
if (1 >= argc - i) {
|
|
|
fprintf(stderr, "%s: requires an argument\n", arg);
|
|
|
@@ -531,7 +523,6 @@ int parse_arguments (int argc, char *argv[])
|
|
|
options.logger_syslog_ident = argv[i + 1];
|
|
|
i++;
|
|
|
}
|
|
|
- #endif
|
|
|
else if (!strcmp(arg, "--loglevel")) {
|
|
|
if (1 >= argc - i) {
|
|
|
fprintf(stderr, "%s: requires an argument\n", arg);
|