mirror of
https://github.com/weechat/weechat.git
synced 2026-06-29 06:16:40 +02:00
Added log directory creation in logger plugin, removed unused log config options in core
This commit is contained in:
+12
-35
@@ -709,29 +709,6 @@ struct t_config_option weechat_options_history[] =
|
||||
{ NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
/* config, log section */
|
||||
|
||||
int cfg_log_plugin_msg;
|
||||
char *cfg_log_path;
|
||||
char *cfg_log_time_format;
|
||||
|
||||
struct t_config_option weechat_options_log[] =
|
||||
{ { "log_plugin_msg",
|
||||
N_("log messages from plugins"),
|
||||
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE, NULL, NULL,
|
||||
&cfg_log_plugin_msg, NULL, weechat_config_change_noop },
|
||||
{ "log_path",
|
||||
N_("path for WeeChat log files ('%h' will be replaced by WeeChat home, "
|
||||
"~/.weechat by default)"),
|
||||
OPTION_TYPE_STRING, 0, 0, 0, "%h/logs/", NULL,
|
||||
NULL, &cfg_log_path, weechat_config_change_noop },
|
||||
{ "log_time_format",
|
||||
N_("time format for log (see man strftime for date/time specifiers)"),
|
||||
OPTION_TYPE_STRING, 0, 0, 0, "%Y %b %d %H:%M:%S", NULL,
|
||||
NULL, &cfg_log_time_format, weechat_config_change_noop },
|
||||
{ NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
/* config, proxy section */
|
||||
|
||||
int cfg_proxy_use;
|
||||
@@ -810,41 +787,41 @@ struct t_config_option weechat_options_plugins[] =
|
||||
|
||||
char *weechat_config_sections[] =
|
||||
{ "look", "colors",
|
||||
"history", "log",
|
||||
"proxy", "plugins",
|
||||
"alias", "keys",
|
||||
"history", "proxy",
|
||||
"plugins", "alias",
|
||||
"keys",
|
||||
NULL
|
||||
};
|
||||
|
||||
struct t_config_option *weechat_config_options[] =
|
||||
{ weechat_options_look, weechat_options_colors,
|
||||
weechat_options_history, weechat_options_log,
|
||||
weechat_options_proxy, weechat_options_plugins,
|
||||
NULL, NULL,
|
||||
weechat_options_history, weechat_options_proxy,
|
||||
weechat_options_plugins, NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
t_config_func_read_option *weechat_config_read_functions[] =
|
||||
{ config_file_read_option, config_file_read_option,
|
||||
config_file_read_option, config_file_read_option,
|
||||
config_file_read_option, config_file_read_option,
|
||||
weechat_config_read_alias, weechat_config_read_key,
|
||||
config_file_read_option, weechat_config_read_alias,
|
||||
weechat_config_read_key,
|
||||
NULL
|
||||
};
|
||||
|
||||
t_config_func_write_options *weechat_config_write_functions[] =
|
||||
{ config_file_write_options, config_file_write_options,
|
||||
config_file_write_options, config_file_write_options,
|
||||
config_file_write_options, config_file_write_options,
|
||||
weechat_config_write_alias, weechat_config_write_keys,
|
||||
config_file_write_options, weechat_config_write_alias,
|
||||
weechat_config_write_keys,
|
||||
NULL
|
||||
};
|
||||
|
||||
t_config_func_write_options *weechat_config_write_default_functions[] =
|
||||
{ config_file_write_options_default_values, config_file_write_options_default_values,
|
||||
config_file_write_options_default_values, config_file_write_options_default_values,
|
||||
config_file_write_options_default_values, config_file_write_options_default_values,
|
||||
weechat_config_write_alias_default_values, weechat_config_write_keys_default_values,
|
||||
config_file_write_options_default_values, weechat_config_write_alias_default_values,
|
||||
weechat_config_write_keys_default_values,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
+1
-10
@@ -157,11 +157,6 @@ extern int cfg_history_max_lines;
|
||||
extern int cfg_history_max_commands;
|
||||
extern int cfg_history_display_default;
|
||||
|
||||
extern struct t_config_option weechat_options_log[];
|
||||
extern int cfg_log_plugin_msg;
|
||||
extern char *cfg_log_path;
|
||||
extern char *cfg_log_time_format;
|
||||
|
||||
extern struct t_config_option weechat_options_proxy[];
|
||||
extern int cfg_proxy_use;
|
||||
extern int cfg_proxy_type;
|
||||
@@ -189,22 +184,18 @@ extern void weechat_config_change_buffer_time_format ();
|
||||
extern void weechat_config_change_hotlist ();
|
||||
extern void weechat_config_change_read_marker ();
|
||||
extern void weechat_config_change_prefix ();
|
||||
extern void weechat_config_change_charset ();
|
||||
extern void weechat_config_change_color ();
|
||||
extern void weechat_config_change_nicks_colors ();
|
||||
extern void weechat_config_change_away_check ();
|
||||
extern void weechat_config_change_fifo_pipe ();
|
||||
extern void weechat_config_change_log ();
|
||||
|
||||
extern int weechat_config_read_alias (struct t_config_option *, char *, char *);
|
||||
extern int weechat_config_read_key (struct t_config_option *, char *, char *);
|
||||
extern int weechat_config_read ();
|
||||
extern int weechat_config_write_alias (FILE *, char *, struct t_config_option *);
|
||||
extern int weechat_config_write_keys (FILE *, char *, struct t_config_option *);
|
||||
extern int weechat_config_write_alias_default_values (FILE *, char *,
|
||||
struct t_config_option *);
|
||||
extern int weechat_config_write_keys_default_values (FILE *, char *,
|
||||
struct t_config_option *);
|
||||
extern int weechat_config_read ();
|
||||
extern int weechat_config_write ();
|
||||
extern void weechat_config_print_stdout ();
|
||||
|
||||
|
||||
@@ -407,29 +407,6 @@ weechat_create_home_dirs ()
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_create_config_dirs: create config directories (read from config file)
|
||||
*/
|
||||
|
||||
void
|
||||
weechat_create_config_dirs ()
|
||||
{
|
||||
char *dir1, *dir2;
|
||||
|
||||
/* create logs directory" */
|
||||
dir1 = string_replace (cfg_log_path, "~", getenv ("HOME"));
|
||||
if (dir1)
|
||||
{
|
||||
dir2 = string_replace (dir1, "%h", weechat_home);
|
||||
if (dir2)
|
||||
{
|
||||
(void) util_create_dir (dir2, 0700);
|
||||
free (dir2);
|
||||
}
|
||||
free (dir1);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_init_vars: initialize some variables
|
||||
*/
|
||||
@@ -620,7 +597,6 @@ main (int argc, char *argv[])
|
||||
weechat_log_init (); /* init log file */
|
||||
if (weechat_config_read () < 0) /* read WeeChat configuration */
|
||||
exit (EXIT_FAILURE);
|
||||
weechat_create_config_dirs (); /* create config directories */
|
||||
command_index_build (); /* build cmd index for completion */
|
||||
gui_main_init (); /* init WeeChat interface */
|
||||
//if (weechat_session)
|
||||
|
||||
+3
-2
@@ -483,8 +483,9 @@ gui_chat_printf_date (struct t_gui_buffer *buffer, time_t date,
|
||||
date_printed = time (NULL);
|
||||
if (date <= 0)
|
||||
date = date_printed;
|
||||
|
||||
ptr_line = buffer->last_line;
|
||||
|
||||
if (gui_init_ok)
|
||||
ptr_line = buffer->last_line;
|
||||
|
||||
pos = buf;
|
||||
while (pos)
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
@@ -69,6 +70,51 @@ logger_config_read ()
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* logger_create_directory: create logger directory
|
||||
* return 1 if success, 0 if failed
|
||||
*/
|
||||
|
||||
int
|
||||
logger_create_directory ()
|
||||
{
|
||||
int rc;
|
||||
char *dir1, *dir2, *weechat_dir;
|
||||
|
||||
rc = 1;
|
||||
|
||||
dir1 = weechat_string_replace (logger_path, "~", getenv ("HOME"));
|
||||
if (dir1)
|
||||
{
|
||||
weechat_dir = weechat_info_get ("weechat_dir");
|
||||
if (weechat_dir)
|
||||
{
|
||||
dir2 = weechat_string_replace (dir1, "%h", weechat_dir);
|
||||
if (dir2)
|
||||
{
|
||||
if (mkdir (dir2, 0755) < 0)
|
||||
{
|
||||
if (errno != EEXIST)
|
||||
rc = 0;
|
||||
}
|
||||
else
|
||||
chmod (dir2, 0700);
|
||||
free (dir2);
|
||||
}
|
||||
else
|
||||
rc = 0;
|
||||
free (weechat_dir);
|
||||
}
|
||||
else
|
||||
rc = 0;
|
||||
free (dir1);
|
||||
}
|
||||
else
|
||||
rc = 0;
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* logger_get_filename: build log filename for a buffer
|
||||
*/
|
||||
@@ -368,6 +414,8 @@ weechat_plugin_init (struct t_weechat_plugin *plugin)
|
||||
logger_config_read ();
|
||||
if (!logger_path || !logger_time_format)
|
||||
return PLUGIN_RC_FAILED;
|
||||
if (!logger_create_directory ())
|
||||
return PLUGIN_RC_FAILED;
|
||||
|
||||
logger_start_buffer_all ();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user