Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow daemon to log to stdout as journald can still log the output #2591

Merged
merged 1 commit into from
Apr 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Comment on lines +29 to +31
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lminiero Is this description good enough?

.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