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

logger: add option logger.file.log_conditions (closes #1942)

This commit is contained in:
Sébastien Helleu
2023-05-20 17:07:55 +02:00
parent 7461a5cb87
commit c3c218035a
29 changed files with 449 additions and 84 deletions
+1
View File
@@ -52,6 +52,7 @@ New features::
* irc: use key when /joining in open channel buffer (issue #1260)
* irc: add option `buffer` in command `/autojoin sort` (issue #1876)
* irc: add `${username}` in server options "nicks" and "username", change their default values to use it
* logger: add option logger.file.log_conditions (issue #1942)
* logger: add info "logger_log_file"
* relay: rename "ssl" options and protocol to "tls"
* relay: make TLS certificate/key loading error handling more verbose (issue #1558)
+1
View File
@@ -445,6 +445,7 @@ WeeChat "core" is located in following directories:
|             test-irc-server.cpp | Tests: IRC server.
|             test-irc-tag.cpp | Tests: IRC message tags.
|          logger/ | Root of unit tests for logger plugin.
|             test-logger.cpp | Tests: logger.
|             test-logger-backlog.cpp | Tests: logger backlog.
|          trigger/ | Root of unit tests for trigger plugin.
|             test-trigger.cpp | Tests: triggers.
+1
View File
@@ -447,6 +447,7 @@ Le cœur de WeeChat est situé dans les répertoires suivants :
|             test-irc-server.cpp | Tests : serveur IRC.
|             test-irc-tag.cpp | Tests : étiquettes des messages IRC.
|          logger/ | Racine des tests unitaires pour l'extension logger.
|             test-logger.cpp | Tests : logger.
|             test-logger-backlog.cpp | Tests : backlog logger.
|          trigger/ | Racine des tests unitaires pour l'extension trigger.
|             test-trigger.cpp | Tests : triggers.
+2
View File
@@ -496,6 +496,8 @@ WeeChat "core" は以下のディレクトリに配置されています:
// TRANSLATION MISSING
|          logger/ | Root of unit tests for logger plugin.
// TRANSLATION MISSING
|             test-logger.cpp | Tests: logger.
// TRANSLATION MISSING
|             test-logger-backlog.cpp | Tests: logger backlog.
// TRANSLATION MISSING
|          trigger/ | Root of unit tests for trigger plugin.
+2
View File
@@ -449,6 +449,8 @@ WeeChat „језгро” се налази у следећим директо
|             test-irc-server.cpp | Тестови: IRC сервер.
|             test-irc-tag.cpp | Тестови: IRC ознаке порука.
|          logger/ | Корен unit тестива за logger додатак.
// TRANSLATION MISSING
|             test-logger.cpp | Tests: logger.
|             test-logger-backlog.cpp | Тестови: logger заостатак.
|          trigger/ | Корен unit тестова за окидач додатак.
|             test-trigger.cpp | Тестови: окидачи.
+7 -1
View File
@@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2023-05-18 11:42+0200\n"
"POT-Creation-Date: 2023-05-20 16:55+0200\n"
"PO-Revision-Date: 2023-05-01 20:23+0200\n"
"Last-Translator: Ondřej Súkup <mimi.vx@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -10802,6 +10802,12 @@ msgstr ""
"zapsat informační řádek do logovacího souboru při spuštění nebo skončení pro "
"buffer"
msgid ""
"conditions to save content of buffers to files (note: content is evaluated, "
"see /help eval); empty value saves content on all buffers; for example to "
"log only private buffers: \"${type} == private\""
msgstr ""
#, fuzzy
msgid ""
"default file name mask for log files (format is \"directory/to/file\" or "
+16 -1
View File
@@ -26,7 +26,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2023-05-18 11:42+0200\n"
"POT-Creation-Date: 2023-05-20 16:55+0200\n"
"PO-Revision-Date: 2023-05-14 15:49+0200\n"
"Last-Translator: Nils Görs <weechatter@arcor.de>\n"
"Language-Team: German <kde-i18n-de@kde.org>\n"
@@ -13170,6 +13170,21 @@ msgstr ""
"fügt eine Information in die Protokoll-Datei ein, wenn die Protokollierung "
"gestartet oder beendet wird"
#, fuzzy
#| msgid ""
#| "conditions to display the backlog (note: content is evaluated, see /help "
#| "eval); empty value displays the backlog on all buffers; for example to "
#| "display backlog on private buffers only: \"${type} == private\""
msgid ""
"conditions to save content of buffers to files (note: content is evaluated, "
"see /help eval); empty value saves content on all buffers; for example to "
"log only private buffers: \"${type} == private\""
msgstr ""
"Bedingungen um die Protokolldatei anzuzeigen (Hinweis: Der Inhalt ist "
"evaluiert, siehe /help eval); wird kein Wert angegeben, wird die "
"Protokolldatei bei allen Buffern angezeigt ; Beispiel: um nur bei privaten "
"Buffern die Protokolldatei anzuzeigen: \"${type} == private\""
msgid ""
"default file name mask for log files (format is \"directory/to/file\" or "
"\"file\", without first \"/\" because \"path\" option is used to build "
+7 -1
View File
@@ -22,7 +22,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2023-05-18 11:42+0200\n"
"POT-Creation-Date: 2023-05-20 16:55+0200\n"
"PO-Revision-Date: 2023-05-01 20:23+0200\n"
"Last-Translator: Santiago Forero <santiago@forero.xyz>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -11537,6 +11537,12 @@ msgstr ""
"escribir una línea informativa en el registro cuando el registro empieza o "
"termina en un buffer"
msgid ""
"conditions to save content of buffers to files (note: content is evaluated, "
"see /help eval); empty value saves content on all buffers; for example to "
"log only private buffers: \"${type} == private\""
msgstr ""
#, fuzzy
msgid ""
"default file name mask for log files (format is \"directory/to/file\" or "
+12 -2
View File
@@ -21,8 +21,8 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2023-05-18 11:42+0200\n"
"PO-Revision-Date: 2023-05-18 11:51+0200\n"
"POT-Creation-Date: 2023-05-20 16:55+0200\n"
"PO-Revision-Date: 2023-05-20 16:59+0200\n"
"Last-Translator: Sébastien Helleu <flashcode@flashtux.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
"Language: fr\n"
@@ -12866,6 +12866,16 @@ msgstr ""
"écrire une ligne d'information dans le fichier log quand le log démarre ou "
"se termine pour un tampon"
msgid ""
"conditions to save content of buffers to files (note: content is evaluated, "
"see /help eval); empty value saves content on all buffers; for example to "
"log only private buffers: \"${type} == private\""
msgstr ""
"conditions pour sauver le contenu des tampons dans des fichiers (note : le "
"contenu est évalué, voir /help eval) ; une valeur vide sauve le contenu de "
"tous les tampons ; par exemple pour sauver uniquement les tampons privés : "
"\"${type} == private\""
msgid ""
"default file name mask for log files (format is \"directory/to/file\" or "
"\"file\", without first \"/\" because \"path\" option is used to build "
+7 -1
View File
@@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2023-05-18 11:42+0200\n"
"POT-Creation-Date: 2023-05-20 16:55+0200\n"
"PO-Revision-Date: 2023-05-01 20:23+0200\n"
"Last-Translator: Andras Voroskoi <voroskoi@frugalware.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -10183,6 +10183,12 @@ msgstr ""
msgid "write information line in log file when log starts or ends for a buffer"
msgstr ""
msgid ""
"conditions to save content of buffers to files (note: content is evaluated, "
"see /help eval); empty value saves content on all buffers; for example to "
"log only private buffers: \"${type} == private\""
msgstr ""
msgid ""
"default file name mask for log files (format is \"directory/to/file\" or "
"\"file\", without first \"/\" because \"path\" option is used to build "
+7 -1
View File
@@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2023-05-18 11:42+0200\n"
"POT-Creation-Date: 2023-05-20 16:55+0200\n"
"PO-Revision-Date: 2023-05-01 20:23+0200\n"
"Last-Translator: Esteban I. Ruiz Moreno <exio4.com@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -11259,6 +11259,12 @@ msgstr ""
"scrive una riga informativa nel file di log quando il log inizia o termina "
"per un buffer"
msgid ""
"conditions to save content of buffers to files (note: content is evaluated, "
"see /help eval); empty value saves content on all buffers; for example to "
"log only private buffers: \"${type} == private\""
msgstr ""
#, fuzzy
msgid ""
"default file name mask for log files (format is \"directory/to/file\" or "
+16 -1
View File
@@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2023-05-18 11:42+0200\n"
"POT-Creation-Date: 2023-05-20 16:55+0200\n"
"PO-Revision-Date: 2023-05-01 20:23+0200\n"
"Last-Translator: AYANOKOUZI, Ryuunosuke <i38w7i3@yahoo.co.jp>\n"
"Language-Team: Japanese <https://github.com/l/weechat/tree/master/"
@@ -12458,6 +12458,21 @@ msgstr ""
msgid "write information line in log file when log starts or ends for a buffer"
msgstr "バッファのログ保存の開始時と終了時にログファイルへ情報行を書き込む"
#, fuzzy
#| msgid ""
#| "conditions to display the backlog (note: content is evaluated, see /help "
#| "eval); empty value displays the backlog on all buffers; for example to "
#| "display backlog on private buffers only: \"${type} == private\""
msgid ""
"conditions to save content of buffers to files (note: content is evaluated, "
"see /help eval); empty value saves content on all buffers; for example to "
"log only private buffers: \"${type} == private\""
msgstr ""
"バックログの表示条件 (注意: 内容は評価されません、/help eval を参照してくださ"
"い); 値が空の場合、すべてのバッファでバックログを表示します; 例えばプライベー"
"トバッファのみでバックログを表示するには、\"${type} == private\" のように値を"
"設定します"
msgid ""
"default file name mask for log files (format is \"directory/to/file\" or "
"\"file\", without first \"/\" because \"path\" option is used to build "
+16 -1
View File
@@ -22,7 +22,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2023-05-18 11:42+0200\n"
"POT-Creation-Date: 2023-05-20 16:55+0200\n"
"PO-Revision-Date: 2023-05-01 20:23+0200\n"
"Last-Translator: Krzysztof Korościk <soltys@soltys.info>\n"
"Language-Team: Polish <kde-i18n-doc@kde.org>\n"
@@ -13448,6 +13448,21 @@ msgstr ""
"zapisuje informacje w pliku z logami o rozpoczęciu i zakończeniu logowania "
"buforu"
#, fuzzy
#| msgid ""
#| "conditions to display the backlog (note: content is evaluated, see /help "
#| "eval); empty value displays the backlog on all buffers; for example to "
#| "display backlog on private buffers only: \"${type} == private\""
msgid ""
"conditions to save content of buffers to files (note: content is evaluated, "
"see /help eval); empty value saves content on all buffers; for example to "
"log only private buffers: \"${type} == private\""
msgstr ""
"warunki do wyświetlania backlogu (uwaga: zawartość jest przetwarzana, "
"zobacz /help eval); pusta wartość wyświetla backlog we wszystkich buforach; "
"na przykład żeby wyświetlić backlog tylko w prywatnych buforach: \"${type} "
"== private\""
msgid ""
"default file name mask for log files (format is \"directory/to/file\" or "
"\"file\", without first \"/\" because \"path\" option is used to build "
+7 -1
View File
@@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2023-05-18 11:42+0200\n"
"POT-Creation-Date: 2023-05-20 16:55+0200\n"
"PO-Revision-Date: 2023-05-01 20:23+0200\n"
"Last-Translator: Vasco Almeida <vascomalmeida@sapo.pt>\n"
"Language-Team: Portuguese <>\n"
@@ -12232,6 +12232,12 @@ msgstr ""
"escrever linha de informação no ficheiro de registo quando o registo de um "
"buffer inicia ou termina"
msgid ""
"conditions to save content of buffers to files (note: content is evaluated, "
"see /help eval); empty value saves content on all buffers; for example to "
"log only private buffers: \"${type} == private\""
msgstr ""
msgid ""
"default file name mask for log files (format is \"directory/to/file\" or "
"\"file\", without first \"/\" because \"path\" option is used to build "
+7 -1
View File
@@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2023-05-18 11:42+0200\n"
"POT-Creation-Date: 2023-05-20 16:55+0200\n"
"PO-Revision-Date: 2023-05-01 20:23+0200\n"
"Last-Translator: Érico Nogueira <ericonr@disroot.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -10755,6 +10755,12 @@ msgstr ""
"escrever linha de informação no arquivo de registro quando o registro "
"começar ou terminar para um buffer"
msgid ""
"conditions to save content of buffers to files (note: content is evaluated, "
"see /help eval); empty value saves content on all buffers; for example to "
"log only private buffers: \"${type} == private\""
msgstr ""
#, fuzzy
msgid ""
"default file name mask for log files (format is \"directory/to/file\" or "
+7 -1
View File
@@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2023-05-18 11:42+0200\n"
"POT-Creation-Date: 2023-05-20 16:55+0200\n"
"PO-Revision-Date: 2023-05-01 20:23+0200\n"
"Last-Translator: Aleksey V Zapparov AKA ixti <ixti@member.fsf.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -10221,6 +10221,12 @@ msgstr ""
msgid "write information line in log file when log starts or ends for a buffer"
msgstr ""
msgid ""
"conditions to save content of buffers to files (note: content is evaluated, "
"see /help eval); empty value saves content on all buffers; for example to "
"log only private buffers: \"${type} == private\""
msgstr ""
msgid ""
"default file name mask for log files (format is \"directory/to/file\" or "
"\"file\", without first \"/\" because \"path\" option is used to build "
+16 -1
View File
@@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2023-05-18 11:42+0200\n"
"POT-Creation-Date: 2023-05-20 16:55+0200\n"
"PO-Revision-Date: 2023-05-14 15:29+0200\n"
"Last-Translator: Ivan Pešić <ivan.pesic@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -12622,6 +12622,21 @@ msgstr ""
"упис линије са информацијама у лог фајл када се започне или заустави "
"логовање за бафер"
#, fuzzy
#| msgid ""
#| "conditions to display the backlog (note: content is evaluated, see /help "
#| "eval); empty value displays the backlog on all buffers; for example to "
#| "display backlog on private buffers only: \"${type} == private\""
msgid ""
"conditions to save content of buffers to files (note: content is evaluated, "
"see /help eval); empty value saves content on all buffers; for example to "
"log only private buffers: \"${type} == private\""
msgstr ""
"услови под којима се приказују старије линије (напомена: садржај се "
"израчунава, погледајте /help eval); празна вредност приказује старије линије "
"на свим баферима; на пример, ако желите да се старије линије приказују само "
"за приватне бафере: „${type} == private”"
msgid ""
"default file name mask for log files (format is \"directory/to/file\" or "
"\"file\", without first \"/\" because \"path\" option is used to build "
+16 -1
View File
@@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2023-05-18 11:42+0200\n"
"POT-Creation-Date: 2023-05-20 16:55+0200\n"
"PO-Revision-Date: 2023-05-01 20:23+0200\n"
"Last-Translator: Emir SARI <emir_sari@icloud.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -13008,6 +13008,21 @@ msgstr ""
"bir arabellek için günlük başladığında veya bittiğinde bilgi satırını günlük "
"dosyasına yaz"
#, fuzzy
#| msgid ""
#| "conditions to display the backlog (note: content is evaluated, see /help "
#| "eval); empty value displays the backlog on all buffers; for example to "
#| "display backlog on private buffers only: \"${type} == private\""
msgid ""
"conditions to save content of buffers to files (note: content is evaluated, "
"see /help eval); empty value saves content on all buffers; for example to "
"log only private buffers: \"${type} == private\""
msgstr ""
"biriken günlüğü görüntüleme koşulları (not: içerik değerlendirilir, bkz. /"
"help eval); boş değer, biriken günlüğü tüm arabelleklerde görüntüler; "
"örneğin biriken günlüğü yalnızca gizli arabelleklerde görüntülemek için: "
"\"${type} == private\""
msgid ""
"default file name mask for log files (format is \"directory/to/file\" or "
"\"file\", without first \"/\" because \"path\" option is used to build "
+7 -1
View File
@@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2023-05-18 11:42+0200\n"
"POT-Creation-Date: 2023-05-20 16:55+0200\n"
"PO-Revision-Date: 2014-08-16 10:27+0200\n"
"Last-Translator: Sébastien Helleu <flashcode@flashtux.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -9209,6 +9209,12 @@ msgstr ""
msgid "write information line in log file when log starts or ends for a buffer"
msgstr ""
msgid ""
"conditions to save content of buffers to files (note: content is evaluated, "
"see /help eval); empty value saves content on all buffers; for example to "
"log only private buffers: \"${type} == private\""
msgstr ""
msgid ""
"default file name mask for log files (format is \"directory/to/file\" or "
"\"file\", without first \"/\" because \"path\" option is used to build "
+5 -57
View File
@@ -46,62 +46,6 @@
#include "logger-tail.h"
/*
* Checks conditions to display the backlog.
*
* Returns:
* 1: conditions OK (backlog is displayed)
* 0: conditions not OK (backlog is NOT displayed)
*/
int
logger_backlog_check_conditions (struct t_gui_buffer *buffer)
{
struct t_hashtable *pointers, *options;
const char *ptr_condition;
char *result;
int condition_ok;
ptr_condition = weechat_config_string (logger_config_look_backlog_conditions);
/* empty condition displays the backlog everywhere */
if (!ptr_condition || !ptr_condition[0])
return 1;
pointers = weechat_hashtable_new (32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_POINTER,
NULL,
NULL);
if (pointers)
{
weechat_hashtable_set (pointers, "window",
weechat_window_search_with_buffer (buffer));
weechat_hashtable_set (pointers, "buffer", buffer);
}
options = weechat_hashtable_new (32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
NULL,
NULL);
if (options)
weechat_hashtable_set (options, "type", "condition");
result = weechat_string_eval_expression (ptr_condition,
pointers, NULL, options);
condition_ok = (result && (strcmp (result, "1") == 0));
if (result)
free (result);
if (pointers)
weechat_hashtable_free (pointers);
if (options)
weechat_hashtable_free (options);
return condition_ok;
}
/*
* Displays a line read from log file.
*/
@@ -227,6 +171,7 @@ logger_backlog_signal_cb (const void *pointer, void *data,
const char *type_data, void *signal_data)
{
struct t_logger_buffer *ptr_logger_buffer;
int rc;
/* make C compiler happy */
(void) pointer;
@@ -237,7 +182,10 @@ logger_backlog_signal_cb (const void *pointer, void *data,
if (weechat_config_integer (logger_config_look_backlog) == 0)
return WEECHAT_RC_OK;
if (!logger_backlog_check_conditions (signal_data))
rc = logger_check_conditions (
signal_data,
weechat_config_string (logger_config_look_backlog_conditions));
if (!rc)
return WEECHAT_RC_OK;
ptr_logger_buffer = logger_buffer_search_buffer (signal_data);
-1
View File
@@ -20,7 +20,6 @@
#ifndef WEECHAT_PLUGIN_LOGGER_BACKLOG_H
#define WEECHAT_PLUGIN_LOGGER_BACKLOG_H
extern int logger_backlog_check_conditions (struct t_gui_buffer *buffer);
extern int logger_backlog_signal_cb (const void *pointer, void *data,
const char *signal,
const char *type_data, void *signal_data);
+4 -1
View File
@@ -713,7 +713,10 @@ logger_buffer_start (struct t_gui_buffer *buffer, int write_info_line)
log_level = logger_get_level_for_buffer (buffer);
log_enabled = weechat_config_boolean (logger_config_file_auto_log)
&& (log_level > 0);
&& (log_level > 0)
&& (logger_check_conditions (
buffer,
weechat_config_string (logger_config_file_log_conditions)));
ptr_logger_buffer = logger_buffer_search_buffer (buffer);
+11
View File
@@ -58,6 +58,7 @@ struct t_config_option *logger_config_file_color_lines = NULL;
struct t_config_option *logger_config_file_flush_delay = NULL;
struct t_config_option *logger_config_file_fsync = NULL;
struct t_config_option *logger_config_file_info_lines = NULL;
struct t_config_option *logger_config_file_log_conditions = NULL;
struct t_config_option *logger_config_file_mask = NULL;
struct t_config_option *logger_config_file_name_lower_case = NULL;
struct t_config_option *logger_config_file_nick_prefix = NULL;
@@ -579,6 +580,16 @@ logger_config_init ()
"a buffer"),
NULL, 0, 0, "off", NULL, 0,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
logger_config_file_log_conditions = weechat_config_new_option (
logger_config_file, logger_config_section_file,
"log_conditions", "string",
N_("conditions to save content of buffers to files "
"(note: content is evaluated, see /help eval); "
"empty value saves content on all buffers; "
"for example to log only private buffers: "
"\"${type} == private\""),
NULL, 0, 0, "", NULL, 0,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
logger_config_file_mask = weechat_config_new_option (
logger_config_file, logger_config_section_file,
"mask", "string",
+1
View File
@@ -34,6 +34,7 @@ extern struct t_config_option *logger_config_file_color_lines;
extern struct t_config_option *logger_config_file_flush_delay;
extern struct t_config_option *logger_config_file_fsync;
extern struct t_config_option *logger_config_file_info_lines;
extern struct t_config_option *logger_config_file_log_conditions;
extern struct t_config_option *logger_config_file_mask;
extern struct t_config_option *logger_config_file_name_lower_case;
extern struct t_config_option *logger_config_file_nick_prefix;
+56
View File
@@ -49,6 +49,62 @@ struct t_hook *logger_hook_timer = NULL; /* timer to flush log files */
struct t_hook *logger_hook_print = NULL;
/*
* Checks conditions against a buffer.
*
* Returns:
* 1: conditions OK
* 0: conditions not OK
*/
int
logger_check_conditions (struct t_gui_buffer *buffer, const char *conditions)
{
struct t_hashtable *pointers, *options;
char *result;
int condition_ok;
if (!buffer)
return 0;
/* empty conditions = always true */
if (!conditions || !conditions[0])
return 1;
pointers = weechat_hashtable_new (32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_POINTER,
NULL,
NULL);
if (pointers)
{
weechat_hashtable_set (pointers, "window",
weechat_window_search_with_buffer (buffer));
weechat_hashtable_set (pointers, "buffer", buffer);
}
options = weechat_hashtable_new (32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
NULL,
NULL);
if (options)
weechat_hashtable_set (options, "type", "condition");
result = weechat_string_eval_expression (conditions,
pointers, NULL, options);
condition_ok = (result && (strcmp (result, "1") == 0));
if (result)
free (result);
if (pointers)
weechat_hashtable_free (pointers);
if (options)
weechat_hashtable_free (options);
return condition_ok;
}
/*
* Gets logger file path option.
*
+2
View File
@@ -34,6 +34,8 @@ extern struct t_weechat_plugin *weechat_logger_plugin;
extern struct t_hook *logger_hook_timer;
extern struct t_hook *logger_hook_print;
extern int logger_check_conditions (struct t_gui_buffer *buffer,
const char *conditions);
extern int logger_create_directory ();
extern char *logger_build_option_name (struct t_gui_buffer *buffer);
extern int logger_get_level_for_buffer (struct t_gui_buffer *buffer);
+1
View File
@@ -89,6 +89,7 @@ endif()
if(ENABLE_LOGGER)
list(APPEND LIB_WEECHAT_UNIT_TESTS_PLUGINS_SRC
unit/plugins/logger/test-logger.cpp
unit/plugins/logger/test-logger-backlog.cpp
)
endif()
@@ -40,16 +40,6 @@ TEST_GROUP(LoggerBacklog)
{
};
/*
* Tests functions:
* logger_backlog_check_conditions
*/
TEST(LoggerBacklog, CheckConditions)
{
/* TODO: write tests */
}
/*
* Tests functions:
* logger_backlog_display_line
+214
View File
@@ -0,0 +1,214 @@
/*
* test-logger.cpp - test logger functions
*
* Copyright (C) 2023 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
* WeeChat is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* WeeChat is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with WeeChat. If not, see <http://www.gnu.org/licenses/>.
*/
#include "CppUTest/TestHarness.h"
#include "tests/tests.h"
extern "C"
{
#include "src/gui/gui-buffer.h"
#include "src/plugins/logger/logger.h"
}
TEST_GROUP(Logger)
{
};
/*
* Tests functions:
* logger_check_conditions
*/
TEST(Logger, CheckConditions)
{
LONGS_EQUAL(0, logger_check_conditions (NULL, NULL));
LONGS_EQUAL(0, logger_check_conditions (NULL, ""));
LONGS_EQUAL(0, logger_check_conditions (NULL, "1"));
LONGS_EQUAL(1, logger_check_conditions (gui_buffers, NULL));
LONGS_EQUAL(1, logger_check_conditions (gui_buffers, ""));
LONGS_EQUAL(1, logger_check_conditions (gui_buffers, "1"));
LONGS_EQUAL(1, logger_check_conditions (gui_buffers, "${name} == weechat"));
LONGS_EQUAL(0, logger_check_conditions (gui_buffers, "0"));
LONGS_EQUAL(0, logger_check_conditions (gui_buffers, "${name} == test"));
}
/*
* Tests functions:
* logger_get_file_path
*/
TEST(Logger, GetFilePath)
{
/* TODO: write tests */
}
/*
* Tests functions:
* logger_create_directory
*/
TEST(Logger, CreateDirectory)
{
/* TODO: write tests */
}
/*
* Tests functions:
* logger_build_option_name
*/
TEST(Logger, BuildOptionName)
{
/* TODO: write tests */
}
/*
* Tests functions:
* logger_get_level_for_buffer
*/
TEST(Logger, GetLevelForBuffer)
{
/* TODO: write tests */
}
/*
* Tests functions:
* logger_get_mask_for_buffer
*/
TEST(Logger, GetMaskForBuffer)
{
/* TODO: write tests */
}
/*
* Tests functions:
* logger_get_mask_expanded
*/
TEST(Logger, GetMaskExpanded)
{
/* TODO: write tests */
}
/*
* Tests functions:
* logger_get_filename
*/
TEST(Logger, GetFilename)
{
/* TODO: write tests */
}
/*
* Tests functions:
* logger_buffer_opened_signal_cb
*/
TEST(Logger, BufferOpenedSignalCb)
{
/* TODO: write tests */
}
/*
* Tests functions:
* logger_buffer_closing_signal_cb
*/
TEST(Logger, BufferClosingSignalCb)
{
/* TODO: write tests */
}
/*
* Tests functions:
* logger_buffer_renamed_signal_cb
*/
TEST(Logger, BufferRenamedSignalCb)
{
/* TODO: write tests */
}
/*
* Tests functions:
* logger_start_signal_cb
*/
TEST(Logger, StartSignalCb)
{
/* TODO: write tests */
}
/*
* Tests functions:
* logger_stop_signal_cb
*/
TEST(Logger, StopSignalCb)
{
/* TODO: write tests */
}
/*
* Tests functions:
* logger_day_changed_signal_cb
*/
TEST(Logger, DayChangedSignalCb)
{
/* TODO: write tests */
}
/*
* Tests functions:
* logger_get_line_tag_info
*/
TEST(Logger, GetLineTagInfo)
{
/* TODO: write tests */
}
/*
* Tests functions:
* logger_print_cb
*/
TEST(Logger, PrintCb)
{
/* TODO: write tests */
}
/*
* Tests functions:
* logger_timer_cb
*/
TEST(Logger, TimerCb)
{
/* TODO: write tests */
}