mirror of
https://github.com/shadowsocks/shadowsocks-libev.git
synced 2026-10-28 03:33:42 +00:00
decouple use_syslog from pid_flags
Sometimes we need processes to run in the foreground to be supervised and at the same time use syslog facility instead of logging its stdout, stderr output
This commit is contained in:
@@ -313,6 +313,12 @@ read_jconf(const char *file)
|
||||
check_json_value_type(value, json_boolean,
|
||||
"invalid config file: option 'ipv6_first' must be a boolean");
|
||||
conf.ipv6_first = value->u.boolean;
|
||||
#ifdef HAS_SYSLOG
|
||||
} else if (strcmp(name, "use_syslog") == 0) {
|
||||
check_json_value_type(value, json_boolean,
|
||||
"invalid config file: option 'use_syslog' must be a boolean");
|
||||
use_syslog = value->u.boolean;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
+1
-1
@@ -1522,8 +1522,8 @@ main(int argc, char **argv)
|
||||
local_addr = "127.0.0.1";
|
||||
}
|
||||
|
||||
USE_SYSLOG(argv[0], pid_flags);
|
||||
if (pid_flags) {
|
||||
USE_SYSLOG(argv[0]);
|
||||
daemonize(pid_path);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1149,8 +1149,8 @@ main(int argc, char **argv)
|
||||
timeout = "60";
|
||||
}
|
||||
|
||||
USE_SYSLOG(argv[0], pid_flags);
|
||||
if (pid_flags) {
|
||||
USE_SYSLOG(argv[0]);
|
||||
daemonize(pid_path);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1140,8 +1140,8 @@ main(int argc, char **argv)
|
||||
#endif
|
||||
}
|
||||
|
||||
USE_SYSLOG(argv[0], pid_flags);
|
||||
if (pid_flags) {
|
||||
USE_SYSLOG(argv[0]);
|
||||
daemonize(pid_path);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1726,8 +1726,8 @@ main(int argc, char **argv)
|
||||
}
|
||||
#endif
|
||||
|
||||
USE_SYSLOG(argv[0], pid_flags);
|
||||
if (pid_flags) {
|
||||
USE_SYSLOG(argv[0]);
|
||||
daemonize(pid_path);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1022,8 +1022,8 @@ main(int argc, char **argv)
|
||||
local_addr = "127.0.0.1";
|
||||
}
|
||||
|
||||
USE_SYSLOG(argv[0], pid_flags);
|
||||
if (pid_flags) {
|
||||
USE_SYSLOG(argv[0]);
|
||||
daemonize(pid_path);
|
||||
}
|
||||
|
||||
|
||||
+11
-7
@@ -35,7 +35,7 @@
|
||||
|
||||
#include <android/log.h>
|
||||
#define USE_TTY()
|
||||
#define USE_SYSLOG(ident)
|
||||
#define USE_SYSLOG(ident, _cond)
|
||||
#define LOGI(...) \
|
||||
((void)__android_log_print(ANDROID_LOG_DEBUG, "shadowsocks", \
|
||||
__VA_ARGS__))
|
||||
@@ -53,7 +53,7 @@
|
||||
extern FILE *logfile;
|
||||
#define TIME_FORMAT "%Y-%m-%d %H:%M:%S"
|
||||
#define USE_TTY()
|
||||
#define USE_SYSLOG(ident)
|
||||
#define USE_SYSLOG(ident, _cond)
|
||||
#define USE_LOGFILE(ident) \
|
||||
do { \
|
||||
if (ident != NULL) { logfile = fopen(ident, "w+"); } } \
|
||||
@@ -99,11 +99,15 @@ extern int use_syslog;
|
||||
use_tty = isatty(STDERR_FILENO); \
|
||||
} while (0)
|
||||
|
||||
#define USE_SYSLOG(ident) \
|
||||
do { \
|
||||
use_syslog = 1; \
|
||||
openlog((ident), LOG_CONS | LOG_PID, 0); } \
|
||||
while (0)
|
||||
#define USE_SYSLOG(_ident, _cond) \
|
||||
do { \
|
||||
if (!use_syslog && (_cond)) { \
|
||||
use_syslog = 1; \
|
||||
} \
|
||||
if (use_syslog) { \
|
||||
openlog((_ident), LOG_CONS | LOG_PID, 0); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define LOGI(format, ...) \
|
||||
do { \
|
||||
|
||||
Reference in New Issue
Block a user