diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/wee-log.c | 11 | ||||
-rw-r--r-- | src/core/weechat.c | 1 | ||||
-rw-r--r-- | src/core/weechat.h | 1 | ||||
-rw-r--r-- | src/gui/curses/headless/main.c | 8 |
4 files changed, 15 insertions, 6 deletions
diff --git a/src/core/wee-log.c b/src/core/wee-log.c index ab441e6cf..a08f1d276 100644 --- a/src/core/wee-log.c +++ b/src/core/wee-log.c @@ -68,17 +68,24 @@ log_open (const char *filename, const char *mode) if (weechat_log_file) return 0; - if (filename) + if (weechat_headless && !weechat_daemon) + { + weechat_log_file = stdout; + } + else if (filename) + { weechat_log_filename = strdup (filename); + weechat_log_file = fopen (weechat_log_filename, mode); + } else { filename_length = strlen (weechat_home) + 64; weechat_log_filename = malloc (filename_length); snprintf (weechat_log_filename, filename_length, "%s/%s", weechat_home, WEECHAT_LOG_NAME); + weechat_log_file = fopen (weechat_log_filename, mode); } - weechat_log_file = fopen (weechat_log_filename, mode); if (!weechat_log_file) { free (weechat_log_filename); diff --git a/src/core/weechat.c b/src/core/weechat.c index 04b09da0c..fd90dbf06 100644 --- a/src/core/weechat.c +++ b/src/core/weechat.c @@ -88,6 +88,7 @@ #define OPTION_NO_GCRYPT 1002 int weechat_headless = 0; /* 1 if running headless (no GUI) */ +int weechat_daemon = 0; /* 1 if daemonized (no foreground) */ int weechat_debug_core = 0; /* debug level for core */ char *weechat_argv0 = NULL; /* WeeChat binary file name (argv[0])*/ int weechat_upgrading = 0; /* =1 if WeeChat is upgrading */ diff --git a/src/core/weechat.h b/src/core/weechat.h index 274d54392..39917851f 100644 --- a/src/core/weechat.h +++ b/src/core/weechat.h @@ -100,6 +100,7 @@ struct t_weelist; /* global variables and functions */ extern int weechat_headless; +extern int weechat_daemon; extern int weechat_debug_core; extern char *weechat_argv0; extern int weechat_upgrading; diff --git a/src/gui/curses/headless/main.c b/src/gui/curses/headless/main.c index 4bb859857..99df53d99 100644 --- a/src/gui/curses/headless/main.c +++ b/src/gui/curses/headless/main.c @@ -88,7 +88,7 @@ daemonize () int main (int argc, char *argv[]) { - int i, daemon; + int i; weechat_init_gettext (); @@ -104,16 +104,16 @@ main (int argc, char *argv[]) * If "--daemon" is received in command line arguments, * daemonize the process. */ - daemon = 0; + weechat_daemon = 0; for (i = 1; i < argc; i++) { if (strcmp (argv[i], "--daemon") == 0) { - daemon = 1; + weechat_daemon = 1; break; } } - if (daemon) + if (weechat_daemon) daemonize (); /* init, main loop and end */ |