summaryrefslogtreecommitdiffhomepage
path: root/src/main.c
diff options
context:
space:
mode:
authorrofl0r <retnyg@gmx.net>2017-11-04 19:40:42 +0000
committerMichael Adam <obnox@samba.org>2017-11-16 19:26:14 +0100
commitccbbb81aa99b75ae87c5b245b495700cd8e03124 (patch)
tree0b79cec23936b80c75a4d86ad0f23db9cd3d89df /src/main.c
parent64b29c5f4e5cf35b9d03fd793e374e27cd83f0b2 (diff)
log to stdout if no logfile specified
some users want to run tinyproxy on an as-needed basis in a terminal, without setting it up permanently to run as a daemon/service. in such use case, it is very annoying that tinyproxy didn't have an option to log to stdout, so the user has to keep a second terminal open to `tail -f` the log. additionally, this precluded usage with runit service supervisor, which runs all services in foreground and creates logfiles from the service's stdout/stderr. since logging to stdout doesn't make sense when daemonized, now if no logfile is specified and daemon mode activated, a warning is printed to stderr once, and nothing is logged. the original idea was to fail with an error message, though some users might actually want to run tinyproxy as daemon and no logging at all.
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/main.c b/src/main.c
index 50cacca..e52b4b2 100644
--- a/src/main.c
+++ b/src/main.c
@@ -355,7 +355,7 @@ static void initialize_config_defaults (struct config_s *conf)
conf->errorpages = NULL;
conf->stathost = safestrdup (TINYPROXY_STATHOST);
conf->idletimeout = MAX_IDLE_TIME;
- conf->logf_name = safestrdup (LOCALSTATEDIR "/log/tinyproxy/tinyproxy.log");
+ conf->logf_name = NULL;
conf->pidpath = NULL;
}
@@ -415,8 +415,13 @@ main (int argc, char **argv)
anonymous_insert ("Content-Type");
}
- if (config.godaemon == TRUE)
+ if (config.godaemon == TRUE) {
+ if (!config.syslog && config.logf_name == NULL)
+ fprintf(stderr, "WARNING: logging deactivated "
+ "(can't log to stdout when daemonized)\n");
+
makedaemon ();
+ }
if (set_signal_handler (SIGPIPE, SIG_IGN) == SIG_ERR) {
fprintf (stderr, "%s: Could not set the \"SIGPIPE\" signal.\n",