Skip to content

Commit

Permalink
core: log to stdout, if headless
Browse files Browse the repository at this point in the history
Fixes #1475 .
  • Loading branch information
tomfitzhenry authored and flashcode committed Apr 19, 2020
1 parent d38701f commit 18a837c
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
1 change: 1 addition & 0 deletions ChangeLog.adoc
Expand Up @@ -20,6 +20,7 @@ https://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes]

New features::

* core: weechat-headless logs to stdout rather than ~/.weechat/weechat.log (issue #1475)
* buflist: evaluate option buflist.look.sort so that sort can be customized for each of the three buflist bar items (issue #1465)
* relay: add command "handshake" in weechat relay protocol and nonce to prevent replay attacks, add options relay.network.password_hash_algo, relay.network.password_hash_iterations, relay.network.nonce_size (issue #1474)
* relay: add option relay.network.auth_timeout
Expand Down
11 changes: 9 additions & 2 deletions src/core/wee-log.c
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/core/weechat.c
Expand Up @@ -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 */
Expand Down
1 change: 1 addition & 0 deletions src/core/weechat.h
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions src/gui/curses/headless/main.c
Expand Up @@ -88,7 +88,7 @@ daemonize ()
int
main (int argc, char *argv[])
{
int i, daemon;
int i;

weechat_init_gettext ();

Expand All @@ -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 */
Expand Down

0 comments on commit 18a837c

Please sign in to comment.