diff --git a/ChangeLog.asciidoc b/ChangeLog.asciidoc index fc732de25..726be9270 100644 --- a/ChangeLog.asciidoc +++ b/ChangeLog.asciidoc @@ -20,6 +20,7 @@ https://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes] === New features * core: add signal "signal_sighup" +* logger: evaluate content of option logger.file.path (issue #388) * relay: display value of HTTP header "X-Real-IP" for websocket connections (closes #440) * script: evaluate content of option script.scripts.dir (issue #388) diff --git a/doc/de/autogen/user/logger_options.asciidoc b/doc/de/autogen/user/logger_options.asciidoc index c2c609a69..887eb3d3f 100644 --- a/doc/de/autogen/user/logger_options.asciidoc +++ b/doc/de/autogen/user/logger_options.asciidoc @@ -48,7 +48,7 @@ ** Werte: beliebige Zeichenkette (Standardwert: `""`) * [[option_logger.file.path]] *logger.file.path* -** Beschreibung: `Pfad für WeeChat Protokolldateien; "%h" wird durch das WeeChat Verzeichnis ersetzt (Standardpfad: "~/.weechat"); eine Datumsspezifikation ist zulässig (siehe: man strftime)` +** Beschreibung: `path for WeeChat log files; "%h" at beginning of string is replaced by WeeChat home ("~/.weechat" by default); date specifiers are permitted (see man strftime) (note: content is evaluated, see /help eval)` ** Typ: Zeichenkette ** Werte: beliebige Zeichenkette (Standardwert: `"%h/logs/"`) diff --git a/doc/en/autogen/user/logger_options.asciidoc b/doc/en/autogen/user/logger_options.asciidoc index 07d42dc2c..50a61eb34 100644 --- a/doc/en/autogen/user/logger_options.asciidoc +++ b/doc/en/autogen/user/logger_options.asciidoc @@ -48,7 +48,7 @@ ** values: any string (default value: `""`) * [[option_logger.file.path]] *logger.file.path* -** description: `path for WeeChat log files; "%h" at beginning of string is replaced by WeeChat home ("~/.weechat" by default); date specifiers are permitted (see man strftime)` +** description: `path for WeeChat log files; "%h" at beginning of string is replaced by WeeChat home ("~/.weechat" by default); date specifiers are permitted (see man strftime) (note: content is evaluated, see /help eval)` ** type: string ** values: any string (default value: `"%h/logs/"`) diff --git a/doc/fr/autogen/user/logger_options.asciidoc b/doc/fr/autogen/user/logger_options.asciidoc index 0279e47f9..de76b9842 100644 --- a/doc/fr/autogen/user/logger_options.asciidoc +++ b/doc/fr/autogen/user/logger_options.asciidoc @@ -48,7 +48,7 @@ ** valeurs: toute chaîne (valeur par défaut: `""`) * [[option_logger.file.path]] *logger.file.path* -** description: `chemin pour les fichiers de log WeeChat ; "%h" au début de la chaîne est remplacé par le répertoire de base WeeChat (par défaut : "~/.weechat") ; les caractères de formatage de date sont autorisés (voir man strftime)` +** description: `chemin pour les fichiers de log WeeChat ; "%h" au début de la chaîne est remplacé par le répertoire de base WeeChat (par défaut : "~/.weechat") ; les caractères de formatage de date sont autorisés (voir man strftime) (note : le contenu est évalué, voir /help eval)` ** type: chaîne ** valeurs: toute chaîne (valeur par défaut: `"%h/logs/"`) diff --git a/doc/it/autogen/user/logger_options.asciidoc b/doc/it/autogen/user/logger_options.asciidoc index 479de0b3a..e45c749ea 100644 --- a/doc/it/autogen/user/logger_options.asciidoc +++ b/doc/it/autogen/user/logger_options.asciidoc @@ -48,7 +48,7 @@ ** valori: qualsiasi stringa (valore predefinito: `""`) * [[option_logger.file.path]] *logger.file.path* -** descrizione: `path per i file di log di WeeChat: "%h" all'inizio della stringa viene sostituito dalla directory home di WeeChat (predefinita è "~/.weechat); sono ammessi gli specificatori di data (consultare man strftime)` +** descrizione: `path for WeeChat log files; "%h" at beginning of string is replaced by WeeChat home ("~/.weechat" by default); date specifiers are permitted (see man strftime) (note: content is evaluated, see /help eval)` ** tipo: stringa ** valori: qualsiasi stringa (valore predefinito: `"%h/logs/"`) diff --git a/doc/ja/autogen/user/logger_options.asciidoc b/doc/ja/autogen/user/logger_options.asciidoc index 96bdb05f5..216350cd6 100644 --- a/doc/ja/autogen/user/logger_options.asciidoc +++ b/doc/ja/autogen/user/logger_options.asciidoc @@ -48,7 +48,7 @@ ** 値: 未制約文字列 (デフォルト値: `""`) * [[option_logger.file.path]] *logger.file.path* -** 説明: `WeeChat ログファイルのパス; 文字列最初の "%h" は WeeChat ホーム (デフォルトでは "~/.weechat") に置換; 日付指定子を使える (strftime の man を参照)` +** 説明: `path for WeeChat log files; "%h" at beginning of string is replaced by WeeChat home ("~/.weechat" by default); date specifiers are permitted (see man strftime) (note: content is evaluated, see /help eval)` ** タイプ: 文字列 ** 値: 未制約文字列 (デフォルト値: `"%h/logs/"`) diff --git a/doc/pl/autogen/user/logger_options.asciidoc b/doc/pl/autogen/user/logger_options.asciidoc index e697edc13..1d98ba051 100644 --- a/doc/pl/autogen/user/logger_options.asciidoc +++ b/doc/pl/autogen/user/logger_options.asciidoc @@ -48,7 +48,7 @@ ** wartości: dowolny ciąg (domyślna wartość: `""`) * [[option_logger.file.path]] *logger.file.path* -** opis: `ścieżka do plików z logami WeeChat; "%h" na początku ciągu zostanie zastąpione przez katalog domowy WeeChat (domyślnie "~/.weechat"); określenia dla daty są dozwolone (zobacz man strftime)` +** opis: `path for WeeChat log files; "%h" at beginning of string is replaced by WeeChat home ("~/.weechat" by default); date specifiers are permitted (see man strftime) (note: content is evaluated, see /help eval)` ** typ: ciąg ** wartości: dowolny ciąg (domyślna wartość: `"%h/logs/"`) diff --git a/po/cs.po b/po/cs.po index 69f9842f6..796823e38 100644 --- a/po/cs.po +++ b/po/cs.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2015-06-19 21:06+0200\n" +"POT-Creation-Date: 2015-06-20 08:05+0200\n" "PO-Revision-Date: 2015-03-21 08:41+0100\n" "Last-Translator: Jiri Golembiovsky \n" "Language-Team: weechat-dev \n" @@ -8597,10 +8597,11 @@ msgstr "" msgid "text to write after nick in prefix of message, example: \">\"" msgstr "" +#, fuzzy msgid "" "path for WeeChat log files; \"%h\" at beginning of string is replaced by " "WeeChat home (\"~/.weechat\" by default); date specifiers are permitted (see " -"man strftime)" +"man strftime) (note: content is evaluated, see /help eval)" msgstr "" "cesta pro logovací soubory WeeChat; \"%h\" na záčátku řetězce je nahrazeno " "domácím adresářem WeeChat (\"~/.weechat\" je výchozí); jsou povoleny " diff --git a/po/de.po b/po/de.po index becbe0d87..3f14873b4 100644 --- a/po/de.po +++ b/po/de.po @@ -24,7 +24,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2015-06-19 21:06+0200\n" +"POT-Creation-Date: 2015-06-20 08:05+0200\n" "PO-Revision-Date: 2015-06-13 22:57+0100\n" "Last-Translator: Nils Görs \n" "Language-Team: German <>\n" @@ -9828,10 +9828,11 @@ msgstr "Zeichenkette, die dem Nick vorangestellt werden soll. Beispiel: \"<\"" msgid "text to write after nick in prefix of message, example: \">\"" msgstr "Zeichenkette, die nach dem Nick eingefügt werden soll. Beispiel: \">\"" +#, fuzzy msgid "" "path for WeeChat log files; \"%h\" at beginning of string is replaced by " "WeeChat home (\"~/.weechat\" by default); date specifiers are permitted (see " -"man strftime)" +"man strftime) (note: content is evaluated, see /help eval)" msgstr "" "Pfad für WeeChat Protokolldateien; \"%h\" wird durch das WeeChat Verzeichnis " "ersetzt (Standardpfad: \"~/.weechat\"); eine Datumsspezifikation ist " diff --git a/po/es.po b/po/es.po index 59a5d40b9..c6d47ef84 100644 --- a/po/es.po +++ b/po/es.po @@ -22,7 +22,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2015-06-19 21:06+0200\n" +"POT-Creation-Date: 2015-06-20 08:05+0200\n" "PO-Revision-Date: 2015-03-21 08:41+0100\n" "Last-Translator: Elián Hanisch \n" "Language-Team: weechat-dev \n" @@ -8901,10 +8901,11 @@ msgstr "" msgid "text to write after nick in prefix of message, example: \">\"" msgstr "" +#, fuzzy msgid "" "path for WeeChat log files; \"%h\" at beginning of string is replaced by " "WeeChat home (\"~/.weechat\" by default); date specifiers are permitted (see " -"man strftime)" +"man strftime) (note: content is evaluated, see /help eval)" msgstr "" "ruta para los registros de WeeChat; \"%h\" al principio de la cadena será " "reemplazado por el directorio raíz de WeeChat (\"~/.weechat\" por defecto); " diff --git a/po/fr.po b/po/fr.po index 1c8a2a511..fb99dce43 100644 --- a/po/fr.po +++ b/po/fr.po @@ -21,8 +21,8 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2015-06-19 21:06+0200\n" -"PO-Revision-Date: 2015-06-19 21:07+0200\n" +"POT-Creation-Date: 2015-06-20 08:05+0200\n" +"PO-Revision-Date: 2015-06-20 08:06+0200\n" "Last-Translator: Sébastien Helleu \n" "Language-Team: weechat-dev \n" "Language: fr\n" @@ -9585,11 +9585,12 @@ msgstr "" msgid "" "path for WeeChat log files; \"%h\" at beginning of string is replaced by " "WeeChat home (\"~/.weechat\" by default); date specifiers are permitted (see " -"man strftime)" +"man strftime) (note: content is evaluated, see /help eval)" msgstr "" "chemin pour les fichiers de log WeeChat ; \"%h\" au début de la chaîne est " "remplacé par le répertoire de base WeeChat (par défaut : \"~/.weechat\") ; " -"les caractères de formatage de date sont autorisés (voir man strftime)" +"les caractères de formatage de date sont autorisés (voir man strftime) " +"(note : le contenu est évalué, voir /help eval)" msgid "" "replacement char for special chars in filename built with mask (like " diff --git a/po/hu.po b/po/hu.po index ca7b35bec..4a720fae3 100644 --- a/po/hu.po +++ b/po/hu.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2015-06-19 21:06+0200\n" +"POT-Creation-Date: 2015-06-20 08:05+0200\n" "PO-Revision-Date: 2015-03-21 08:41+0100\n" "Last-Translator: Andras Voroskoi \n" "Language-Team: weechat-dev \n" @@ -7981,7 +7981,7 @@ msgstr "" msgid "" "path for WeeChat log files; \"%h\" at beginning of string is replaced by " "WeeChat home (\"~/.weechat\" by default); date specifiers are permitted (see " -"man strftime)" +"man strftime) (note: content is evaluated, see /help eval)" msgstr "" "modulok elérési útvonala ('%h' helyére automatikusan a WeeChat saját " "könyvtára, alapértelmezésben ~/.weechat, kerül)" diff --git a/po/it.po b/po/it.po index bf3271513..9684ed203 100644 --- a/po/it.po +++ b/po/it.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2015-06-19 21:06+0200\n" +"POT-Creation-Date: 2015-06-20 08:05+0200\n" "PO-Revision-Date: 2015-03-21 08:41+0100\n" "Last-Translator: Esteban I. Ruiz Moreno \n" "Language-Team: weechat-dev \n" @@ -9056,10 +9056,11 @@ msgid "text to write after nick in prefix of message, example: \">\"" msgstr "" "testo da scrivere dopo il nick nel prefisso del messaggo, esempio: \"<\"" +#, fuzzy msgid "" "path for WeeChat log files; \"%h\" at beginning of string is replaced by " "WeeChat home (\"~/.weechat\" by default); date specifiers are permitted (see " -"man strftime)" +"man strftime) (note: content is evaluated, see /help eval)" msgstr "" "path per i file di log di WeeChat: \"%h\" all'inizio della stringa viene " "sostituito dalla directory home di WeeChat (predefinita è \"~/.weechat); " diff --git a/po/ja.po b/po/ja.po index 69c1c3193..618c910d2 100644 --- a/po/ja.po +++ b/po/ja.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2015-06-19 21:06+0200\n" +"POT-Creation-Date: 2015-06-20 08:05+0200\n" "PO-Revision-Date: 2015-06-09 22:28+0900\n" "Last-Translator: AYANOKOUZI, Ryuunosuke \n" "Language-Team: Japanese \n" @@ -9206,10 +9206,11 @@ msgstr "ニックネームの前に書くテキスト (メッセージプレフ msgid "text to write after nick in prefix of message, example: \">\"" msgstr "ニックネームの後に書くテキスト (メッセージプレフィックス)、例: \">\"" +#, fuzzy msgid "" "path for WeeChat log files; \"%h\" at beginning of string is replaced by " "WeeChat home (\"~/.weechat\" by default); date specifiers are permitted (see " -"man strftime)" +"man strftime) (note: content is evaluated, see /help eval)" msgstr "" "WeeChat ログファイルのパス; 文字列最初の \"%h\" は WeeChat ホーム (デフォルト" "では \"~/.weechat\") に置換; 日付指定子を使える (strftime の man を参照)" diff --git a/po/pl.po b/po/pl.po index 6091eb668..580705b98 100644 --- a/po/pl.po +++ b/po/pl.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2015-06-19 21:06+0200\n" +"POT-Creation-Date: 2015-06-20 08:05+0200\n" "PO-Revision-Date: 2015-05-09 14:00+0100\n" "Last-Translator: Krzysztof Korościk \n" "Language-Team: weechat-dev \n" @@ -9394,10 +9394,11 @@ msgstr "" msgid "text to write after nick in prefix of message, example: \">\"" msgstr "tekst wyświetlany za nickiem w przedrostku wiadomości, przykład: \">\"" +#, fuzzy msgid "" "path for WeeChat log files; \"%h\" at beginning of string is replaced by " "WeeChat home (\"~/.weechat\" by default); date specifiers are permitted (see " -"man strftime)" +"man strftime) (note: content is evaluated, see /help eval)" msgstr "" "ścieżka do plików z logami WeeChat; \"%h\" na początku ciągu zostanie " "zastąpione przez katalog domowy WeeChat (domyślnie \"~/.weechat\"); " diff --git a/po/pt_BR.po b/po/pt_BR.po index 1aef4089b..be33395d2 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2015-06-19 21:06+0200\n" +"POT-Creation-Date: 2015-06-20 08:05+0200\n" "PO-Revision-Date: 2015-03-21 08:41+0100\n" "Last-Translator: Eduardo Elias \n" "Language-Team: weechat-dev \n" @@ -8399,10 +8399,11 @@ msgstr "" msgid "text to write after nick in prefix of message, example: \">\"" msgstr "" +#, fuzzy msgid "" "path for WeeChat log files; \"%h\" at beginning of string is replaced by " "WeeChat home (\"~/.weechat\" by default); date specifiers are permitted (see " -"man strftime)" +"man strftime) (note: content is evaluated, see /help eval)" msgstr "" "diretório para arquivos de registro do WeeChat; \"%h\" no início da string " "será substituído pelo diretório do WeeChat (\"~/.weechat\" por padrão); " diff --git a/po/ru.po b/po/ru.po index c089cc2e6..a2959e09c 100644 --- a/po/ru.po +++ b/po/ru.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2015-06-19 21:06+0200\n" +"POT-Creation-Date: 2015-06-20 08:05+0200\n" "PO-Revision-Date: 2015-03-21 08:41+0100\n" "Last-Translator: Aleksey V Zapparov AKA ixti \n" "Language-Team: weechat-dev \n" @@ -8010,7 +8010,7 @@ msgstr "" msgid "" "path for WeeChat log files; \"%h\" at beginning of string is replaced by " "WeeChat home (\"~/.weechat\" by default); date specifiers are permitted (see " -"man strftime)" +"man strftime) (note: content is evaluated, see /help eval)" msgstr "" "путь поиска pluginов ('%h' заменяется на домашний каталог WeeChat, по " "умолчанию - ~/.weechat)" diff --git a/po/tr.po b/po/tr.po index 7632135f1..52fa49d90 100644 --- a/po/tr.po +++ b/po/tr.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2015-06-19 21:06+0200\n" +"POT-Creation-Date: 2015-06-20 08:05+0200\n" "PO-Revision-Date: 2015-03-10 21:33+0100\n" "Last-Translator: Hasan Kiran \n" "Language-Team: weechat-dev \n" @@ -7218,7 +7218,7 @@ msgstr "" msgid "" "path for WeeChat log files; \"%h\" at beginning of string is replaced by " "WeeChat home (\"~/.weechat\" by default); date specifiers are permitted (see " -"man strftime)" +"man strftime) (note: content is evaluated, see /help eval)" msgstr "" msgid "" diff --git a/po/weechat.pot b/po/weechat.pot index ccdd3a961..96d4be0b6 100644 --- a/po/weechat.pot +++ b/po/weechat.pot @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2015-06-19 21:06+0200\n" +"POT-Creation-Date: 2015-06-20 08:05+0200\n" "PO-Revision-Date: 2014-08-16 10:27+0200\n" "Last-Translator: Sébastien Helleu \n" "Language-Team: weechat-dev \n" @@ -7153,7 +7153,7 @@ msgstr "" msgid "" "path for WeeChat log files; \"%h\" at beginning of string is replaced by " "WeeChat home (\"~/.weechat\" by default); date specifiers are permitted (see " -"man strftime)" +"man strftime) (note: content is evaluated, see /help eval)" msgstr "" msgid "" diff --git a/src/plugins/logger/logger-config.c b/src/plugins/logger/logger-config.c index bd28960c5..cac61d8a9 100644 --- a/src/plugins/logger/logger-config.c +++ b/src/plugins/logger/logger-config.c @@ -470,7 +470,8 @@ logger_config_init () "path", "string", N_("path for WeeChat log files; \"%h\" at beginning of string is " "replaced by WeeChat home (\"~/.weechat\" by default); date " - "specifiers are permitted (see man strftime)"), + "specifiers are permitted (see man strftime) " + "(note: content is evaluated, see /help eval)"), NULL, 0, 0, "%h/logs/", NULL, 0, NULL, NULL, &logger_config_change_file_option_restart_log, NULL, NULL, NULL); logger_config_file_replacement_char = weechat_config_new_option ( diff --git a/src/plugins/logger/logger.c b/src/plugins/logger/logger.c index f2e057caa..ec6d1e651 100644 --- a/src/plugins/logger/logger.c +++ b/src/plugins/logger/logger.c @@ -71,7 +71,7 @@ struct t_hook *logger_timer = NULL; /* timer to flush log files */ char * logger_get_file_path () { - char *file_path, *file_path2, *file_path3; + char *file_path, *file_path2, *file_path3, *file_path4; const char *weechat_dir; int length; time_t seconds; @@ -80,45 +80,52 @@ logger_get_file_path () file_path = NULL; file_path2 = NULL; file_path3 = NULL; + file_path4 = NULL; weechat_dir = weechat_info_get ("weechat_dir", ""); if (!weechat_dir) goto end; - /* replace "~" with user home */ - file_path = weechat_string_expand_home (weechat_config_string (logger_config_file_path)); + /* evaluate path */ + file_path = weechat_string_eval_expression ( + weechat_config_string (logger_config_file_path), NULL, NULL, NULL); if (!file_path) goto end; - /* replace "%h" with WeeChat home (at beginning of string only) */ - if (strncmp (file_path, "%h", 2) == 0) - { - length = strlen (weechat_dir) + strlen (file_path + 2) + 1; - file_path2 = malloc (length); - if (file_path2) - snprintf (file_path2, length, "%s%s", weechat_dir, file_path + 2); - } - else - file_path2 = strdup (file_path); + /* replace "~" with user home */ + file_path2 = weechat_string_expand_home (file_path); if (!file_path2) goto end; - /* replace date/time specifiers in path */ - length = strlen (file_path2) + 256 + 1; - file_path3 = malloc (length); + /* replace "%h" with WeeChat home (at beginning of string only) */ + if (strncmp (file_path2, "%h", 2) == 0) + { + length = strlen (weechat_dir) + strlen (file_path2 + 2) + 1; + file_path3 = malloc (length); + if (file_path3) + snprintf (file_path3, length, "%s%s", weechat_dir, file_path2 + 2); + } + else + file_path3 = strdup (file_path2); if (!file_path3) goto end; + + /* replace date/time specifiers in path */ + length = strlen (file_path3) + 256 + 1; + file_path4 = malloc (length); + if (!file_path4) + goto end; seconds = time (NULL); date_tmp = localtime (&seconds); - file_path3[0] = '\0'; - strftime (file_path3, length - 1, file_path2, date_tmp); + file_path4[0] = '\0'; + strftime (file_path4, length - 1, file_path3, date_tmp); if (weechat_logger_plugin->debug) { weechat_printf_tags (NULL, "no_log", "%s: file path = \"%s\"", - LOGGER_PLUGIN_NAME, file_path3); + LOGGER_PLUGIN_NAME, file_path4); } end: @@ -126,8 +133,10 @@ end: free (file_path); if (file_path2) free (file_path2); + if (file_path3) + free (file_path3); - return file_path3; + return file_path4; } /*