summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2007-11-11 17:05:42 +0100
committerSebastien Helleu <flashcode@flashtux.org>2007-11-11 17:05:42 +0100
commitac30e2226d2aac2dbd6a34bd12aa1c8902010662 (patch)
tree2d10753494c0550eaaa6f204c67963d7a56b7f43 /src
parentcdc08d6fc38d0c81e4826930b266f74a33ca2185 (diff)
downloadweechat-ac30e2226d2aac2dbd6a34bd12aa1c8902010662.zip
Added log directory creation in logger plugin, removed unused log config options in core
Diffstat (limited to 'src')
-rw-r--r--src/core/wee-config.c47
-rw-r--r--src/core/wee-config.h11
-rw-r--r--src/core/weechat.c24
-rw-r--r--src/gui/gui-chat.c5
-rw-r--r--src/plugins/logger/logger.c48
5 files changed, 64 insertions, 71 deletions
diff --git a/src/core/wee-config.c b/src/core/wee-config.c
index 4a8f07d96..b53779555 100644
--- a/src/core/wee-config.c
+++ b/src/core/wee-config.c
@@ -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
};
diff --git a/src/core/wee-config.h b/src/core/wee-config.h
index 2918cb32c..ac62dbe32 100644
--- a/src/core/wee-config.h
+++ b/src/core/wee-config.h
@@ -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 ();
diff --git a/src/core/weechat.c b/src/core/weechat.c
index 14096db44..60ccb3023 100644
--- a/src/core/weechat.c
+++ b/src/core/weechat.c
@@ -408,29 +408,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)
diff --git a/src/gui/gui-chat.c b/src/gui/gui-chat.c
index 8acca3456..c78215325 100644
--- a/src/gui/gui-chat.c
+++ b/src/gui/gui-chat.c
@@ -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)
diff --git a/src/plugins/logger/logger.c b/src/plugins/logger/logger.c
index 0458a0395..3a0690ba6 100644
--- a/src/plugins/logger/logger.c
+++ b/src/plugins/logger/logger.c
@@ -25,6 +25,7 @@
#include <stdlib.h>
#include <unistd.h>
+#include <errno.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
@@ -70,6 +71,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 ();