log to stdout if not running as daemon
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.
This commit is contained in:
parent
3662afc793
commit
2edfc38b8e
@ -70,7 +70,10 @@ static unsigned int logging_initialized = FALSE; /* boolean */
|
|||||||
*/
|
*/
|
||||||
int open_log_file (const char *log_file_name)
|
int open_log_file (const char *log_file_name)
|
||||||
{
|
{
|
||||||
log_file_fd = create_file_safely (log_file_name, FALSE);
|
if (config.godaemon == FALSE)
|
||||||
|
log_file_fd = fileno(stdout);
|
||||||
|
else
|
||||||
|
log_file_fd = create_file_safely (log_file_name, FALSE);
|
||||||
return log_file_fd;
|
return log_file_fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,7 +82,7 @@ int open_log_file (const char *log_file_name)
|
|||||||
*/
|
*/
|
||||||
void close_log_file (void)
|
void close_log_file (void)
|
||||||
{
|
{
|
||||||
if (log_file_fd < 0) {
|
if (log_file_fd < 0 || log_file_fd == fileno(stdout)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ display_usage (void)
|
|||||||
printf ("Usage: %s [options]\n", PACKAGE);
|
printf ("Usage: %s [options]\n", PACKAGE);
|
||||||
printf ("\n"
|
printf ("\n"
|
||||||
"Options are:\n"
|
"Options are:\n"
|
||||||
" -d Do not daemonize (run in foreground).\n"
|
" -d Do not daemonize (run in foreground, log to stdout).\n"
|
||||||
" -c FILE Use an alternate configuration file.\n"
|
" -c FILE Use an alternate configuration file.\n"
|
||||||
" -h Display this usage information.\n"
|
" -h Display this usage information.\n"
|
||||||
" -l Display the license.\n"
|
" -l Display the license.\n"
|
||||||
|
Loading…
Reference in New Issue
Block a user