Skip to content

Commit

Permalink
Added new --log-stdout flag that enabled stdout logging even when dae…
Browse files Browse the repository at this point in the history
…monizing the process
  • Loading branch information
mtorromeo committed Apr 2, 2021
1 parent a85e763 commit 2180a67
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
3 changes: 3 additions & 0 deletions janus.1
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ Open the specified PID file when starting Janus (default=none)
.BR \-N ", " \-\-disable-stdout
Disable stdout based logging (default=off)
.TP
.BR \-L ", " \-\-log-stdout
Log to stdout, even when the process is daemonized (default=off)
.TP
.BR \-L ", " \-\-log-file=\fIpath\fR
Log to the specified file (default=stdout only)
.TP
Expand Down
8 changes: 2 additions & 6 deletions janus.c
Original file line number Diff line number Diff line change
Expand Up @@ -4119,7 +4119,7 @@ gint main(int argc, char *argv[])
if(args_info.disable_stdout_given) {
use_stdout = FALSE;
janus_config_add(config, config_general, janus_config_item_create("log_to_stdout", "no"));
} else {
} else if(!args_info.log_stdout_given) {
/* Check if the configuration file is saying anything about this */
janus_config_item *item = janus_config_get(config, config_general, janus_config_type_item, "log_to_stdout");
if(item && item->value && !janus_is_true(item->value))
Expand Down Expand Up @@ -4147,13 +4147,9 @@ gint main(int argc, char *argv[])
daemonize = TRUE;
}
/* If we're going to daemonize, make sure logging to stdout is disabled and a log file has been specified */
if(daemonize && use_stdout) {
if(daemonize && use_stdout && !args_info.log_stdout_given) {
use_stdout = FALSE;
}
if(daemonize && logfile == NULL) {
g_print("Running Janus as a daemon but no log file provided, giving up...\n");
exit(1);
}
/* Daemonize now, if we need to */
if(daemonize) {
g_print("Running Janus as a daemon\n");
Expand Down
1 change: 1 addition & 0 deletions janus.ggo
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
option "daemon" b "Launch Janus in background as a daemon" flag off
option "pid-file" p "Open the specified PID file when starting Janus (default=none)" string typestr="path" optional
option "disable-stdout" N "Disable stdout based logging" flag off
option "log-stdout" - "Log to stdout, even when the process is daemonized" flag off
option "log-file" L "Log to the specified file (default=stdout only)" string typestr="path" optional
option "cwd-path" H "Working directory for Janus daemon process (default=/)" string typestr="path" optional
option "interface" i "Interface to use (will be the public IP)" string typestr="ipaddress" optional
Expand Down
2 changes: 1 addition & 1 deletion log.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ int janus_log_init(gboolean daemon, gboolean console, const char *logfile) {
g_print("WARNING: logging completely disabled!\n");
g_print(" (no stdout and no logfile, this may not be what you want...)\n");
}
if(daemon) {
if(daemon && !console) {
/* Replace the standard file descriptors */
if (freopen("/dev/null", "r", stdin) == NULL) {
g_print("Error replacing stdin with /dev/null\n");
Expand Down

0 comments on commit 2180a67

Please sign in to comment.