1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-03 16:23:14 +02:00

core: add command line option "--stdout" in weechat-headless binary (closes #1475, closes #1477)

This commit is contained in:
Sébastien Helleu
2020-04-19 11:28:39 +02:00
parent 18a837c55b
commit 0b994d718d
34 changed files with 216 additions and 29 deletions
+6 -3
View File
@@ -68,7 +68,7 @@ log_open (const char *filename, const char *mode)
if (weechat_log_file)
return 0;
if (weechat_headless && !weechat_daemon)
if (weechat_log_stdout)
{
weechat_log_file = stdout;
}
@@ -88,8 +88,11 @@ log_open (const char *filename, const char *mode)
if (!weechat_log_file)
{
free (weechat_log_filename);
weechat_log_filename = NULL;
if (weechat_log_filename)
{
free (weechat_log_filename);
weechat_log_filename = NULL;
}
return 0;
}
+9
View File
@@ -89,6 +89,7 @@
int weechat_headless = 0; /* 1 if running headless (no GUI) */
int weechat_daemon = 0; /* 1 if daemonized (no foreground) */
int weechat_log_stdout = 0; /* 1 to log messages on stdout */
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 */
@@ -194,6 +195,14 @@ weechat_display_usage ()
stdout,
_(" (by default in headless mode "
"WeeChat is blocking and does not run in background)\n"));
string_fprintf (
stdout,
_(" --stdout display log messages on standard "
"output instead of writing them in log file\n"));
string_fprintf (
stdout,
_(" (option ignored if option "
"\"--daemon\" is given)\n"));
string_fprintf (stdout, "\n");
}
+1
View File
@@ -101,6 +101,7 @@ struct t_weelist;
/* global variables and functions */
extern int weechat_headless;
extern int weechat_daemon;
extern int weechat_log_stdout;
extern int weechat_debug_core;
extern char *weechat_argv0;
extern int weechat_upgrading;
+10 -3
View File
@@ -101,8 +101,9 @@ main (int argc, char *argv[])
weechat_headless = 1;
/*
* If "--daemon" is received in command line arguments,
* daemonize the process.
* Parse extra options for headless mode:
* - "--daemon": daemonize the process
* - "--stdout": log messages to stdout (instead of log file)
*/
weechat_daemon = 0;
for (i = 1; i < argc; i++)
@@ -110,11 +111,17 @@ main (int argc, char *argv[])
if (strcmp (argv[i], "--daemon") == 0)
{
weechat_daemon = 1;
break;
}
else if (strcmp (argv[i], "--stdout") == 0)
{
weechat_log_stdout = 1;
}
}
if (weechat_daemon)
{
weechat_log_stdout = 0;
daemonize ();
}
/* init, main loop and end */
weechat_init (argc, argv, &gui_main_init);