mirror of
https://github.com/weechat/weechat.git
synced 2026-06-30 14:56:39 +02:00
Remove debug plugin (merged to core), new debug variable for each plugin (no more signals for setting debug)
This commit is contained in:
@@ -770,6 +770,86 @@ command_command (void *data, struct t_gui_buffer *buffer,
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* command_debug: control debug for core/plugins
|
||||
*/
|
||||
|
||||
int
|
||||
command_debug (void *data, struct t_gui_buffer *buffer,
|
||||
int argc, char **argv, char **argv_eol)
|
||||
{
|
||||
struct t_config_option *ptr_option;
|
||||
struct t_weechat_plugin *ptr_plugin;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) argv_eol;
|
||||
|
||||
if ((argc == 1)
|
||||
|| ((argc == 2) && (string_strcasecmp (argv[1], "list") == 0)))
|
||||
{
|
||||
gui_chat_printf (NULL, "");
|
||||
gui_chat_printf (NULL, "Debug:");
|
||||
|
||||
ptr_option = config_weechat_debug_get (PLUGIN_CORE);
|
||||
gui_chat_printf (NULL, " %s: %d",
|
||||
PLUGIN_CORE,
|
||||
(ptr_option) ? CONFIG_INTEGER(ptr_option) : 0);
|
||||
for (ptr_plugin = weechat_plugins; ptr_plugin;
|
||||
ptr_plugin = ptr_plugin->next_plugin)
|
||||
{
|
||||
gui_chat_printf (NULL, " %s: %d",
|
||||
ptr_plugin->name,
|
||||
ptr_plugin->debug);
|
||||
}
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
if (string_strcasecmp (argv[1], "dump") == 0)
|
||||
{
|
||||
hook_signal_send ("debug_dump", WEECHAT_HOOK_SIGNAL_STRING, NULL);
|
||||
}
|
||||
else if (string_strcasecmp (argv[1], "buffer") == 0)
|
||||
{
|
||||
gui_buffer_dump_hexa (buffer);
|
||||
}
|
||||
else if (string_strcasecmp (argv[1], "windows") == 0)
|
||||
{
|
||||
debug_windows_tree ();
|
||||
}
|
||||
else if (argc >= 3)
|
||||
{
|
||||
if (strcmp (argv[2], "0") == 0)
|
||||
{
|
||||
/* disable debug for a plugin */
|
||||
ptr_option = config_weechat_debug_get (argv[1]);
|
||||
if (ptr_option)
|
||||
{
|
||||
config_file_option_free (ptr_option);
|
||||
config_weechat_debug_set_all ();
|
||||
gui_chat_printf (NULL, _("Debug disabled for \"%s\""),
|
||||
argv[1]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* set debug level for a plugin */
|
||||
if (config_weechat_debug_set (argv[1], argv[2]) != WEECHAT_CONFIG_OPTION_SET_ERROR)
|
||||
{
|
||||
ptr_option = config_weechat_debug_get (argv[1]);
|
||||
if (ptr_option)
|
||||
{
|
||||
gui_chat_printf (NULL, "%s: \"%s\" => %d",
|
||||
"debug", argv[1],
|
||||
CONFIG_INTEGER(ptr_option));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* command_filter_display: display one filter
|
||||
*/
|
||||
@@ -3133,6 +3213,20 @@ command_init ()
|
||||
"added if not found at beginning of command)"),
|
||||
"%p|weechat %P",
|
||||
&command_command, NULL);
|
||||
hook_command (NULL, "debug",
|
||||
N_("control debug for core/plugins"),
|
||||
N_("[list | plugin level | dump | buffer | windows]"),
|
||||
N_(" plugin: name of plugin (\"core\" for WeeChat core)\n"
|
||||
" level: debug level for plugin (0 = disable debug)\n"
|
||||
" dump: save memory dump in WeeChat log file (same "
|
||||
"dump is written when WeeChat crashes)\n"
|
||||
" buffer: dump buffer content with hexadecimal values "
|
||||
"in log file\n"
|
||||
"windows: display windows tree\n"
|
||||
" text: send \"debug\" signal with \"text\" as "
|
||||
"argument"),
|
||||
"%p|list|dump|buffer|windows",
|
||||
&command_debug, NULL);
|
||||
hook_command (NULL, "filter",
|
||||
N_("filter messages in buffers, to hide/show them according "
|
||||
"to tags or regex"),
|
||||
|
||||
+161
-1
@@ -35,7 +35,6 @@
|
||||
|
||||
#include "weechat.h"
|
||||
#include "wee-config.h"
|
||||
#include "wee-config-file.h"
|
||||
#include "wee-hook.h"
|
||||
#include "wee-log.h"
|
||||
#include "wee-util.h"
|
||||
@@ -55,6 +54,7 @@
|
||||
|
||||
|
||||
struct t_config_file *weechat_config_file = NULL;
|
||||
struct t_config_section *weechat_config_section_debug = NULL;
|
||||
struct t_config_section *weechat_config_section_bar = NULL;
|
||||
|
||||
/* config, startup section */
|
||||
@@ -484,6 +484,151 @@ config_weechat_reload (void *data, struct t_config_file *config_file)
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* config_weechat_debug_get: get debug level for a plugin (or "core")
|
||||
*/
|
||||
|
||||
struct t_config_option *
|
||||
config_weechat_debug_get (const char *plugin_name)
|
||||
{
|
||||
return config_file_search_option (weechat_config_file,
|
||||
weechat_config_section_debug,
|
||||
plugin_name);
|
||||
}
|
||||
|
||||
/*
|
||||
* config_weechat_debug_set_all: set debug for "core" and all plugins, using
|
||||
* values from [debug] section
|
||||
*/
|
||||
|
||||
void
|
||||
config_weechat_debug_set_all ()
|
||||
{
|
||||
struct t_config_option *ptr_option;
|
||||
struct t_weechat_plugin *ptr_plugin;
|
||||
|
||||
/* set debug for core */
|
||||
ptr_option = config_weechat_debug_get (PLUGIN_CORE);
|
||||
weechat_debug_core = (ptr_option) ? CONFIG_INTEGER(ptr_option) : 0;
|
||||
|
||||
/* set debug for plugins */
|
||||
for (ptr_plugin = weechat_plugins; ptr_plugin;
|
||||
ptr_plugin = ptr_plugin->next_plugin)
|
||||
{
|
||||
ptr_option = config_weechat_debug_get (ptr_plugin->name);
|
||||
ptr_plugin->debug = (ptr_option) ? CONFIG_INTEGER(ptr_option) : 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* config_weechat_debug_change: called when a debug option is changed
|
||||
*/
|
||||
|
||||
void
|
||||
config_weechat_debug_change (void *data,
|
||||
struct t_config_option *option)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
config_weechat_debug_set_all ();
|
||||
}
|
||||
|
||||
/*
|
||||
* config_weechat_debug_create_option: create option in "debug" section
|
||||
*/
|
||||
|
||||
int
|
||||
config_weechat_debug_create_option (void *data,
|
||||
struct t_config_file *config_file,
|
||||
struct t_config_section *section,
|
||||
const char *option_name,
|
||||
const char *value)
|
||||
{
|
||||
struct t_config_option *ptr_option;
|
||||
int rc;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
|
||||
|
||||
if (option_name)
|
||||
{
|
||||
ptr_option = config_file_search_option (config_file, section,
|
||||
option_name);
|
||||
if (ptr_option)
|
||||
{
|
||||
if (value && value[0])
|
||||
rc = config_file_option_set (ptr_option, value, 1);
|
||||
else
|
||||
{
|
||||
config_file_option_free (ptr_option);
|
||||
rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (value && value[0])
|
||||
{
|
||||
ptr_option = config_file_new_option (
|
||||
config_file, section,
|
||||
option_name, "integer",
|
||||
_("debug level for plugin (\"core\" for WeeChat core)"),
|
||||
NULL, 0, 32, "0", value, NULL, NULL,
|
||||
&config_weechat_debug_change, NULL,
|
||||
NULL, NULL);
|
||||
rc = (ptr_option) ?
|
||||
WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE : WEECHAT_CONFIG_OPTION_SET_ERROR;
|
||||
}
|
||||
else
|
||||
rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
/* set debug level for "core" and all plugins */
|
||||
config_weechat_debug_set_all ();
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* config_weechat_debug_delete_option: delete option in "debug" section
|
||||
*/
|
||||
|
||||
int
|
||||
config_weechat_debug_delete_option (void *data,
|
||||
struct t_config_file *config_file,
|
||||
struct t_config_section *section,
|
||||
struct t_config_option *option)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) config_file;
|
||||
(void) section;
|
||||
|
||||
config_file_option_free (option);
|
||||
|
||||
config_weechat_debug_set_all ();
|
||||
|
||||
return WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED;
|
||||
}
|
||||
|
||||
/*
|
||||
* config_weechat_debug_set: set debug level for a plugin (or "core")
|
||||
*/
|
||||
|
||||
int
|
||||
config_weechat_debug_set (const char *plugin_name, const char *value)
|
||||
{
|
||||
return config_weechat_debug_create_option (NULL,
|
||||
weechat_config_file,
|
||||
weechat_config_section_debug,
|
||||
plugin_name,
|
||||
value);
|
||||
}
|
||||
|
||||
/*
|
||||
* config_weechat_bar_read: read bar option in config file
|
||||
*/
|
||||
@@ -821,6 +966,21 @@ config_weechat_init ()
|
||||
if (!weechat_config_file)
|
||||
return 0;
|
||||
|
||||
/* debug */
|
||||
ptr_section = config_file_new_section (weechat_config_file, "debug",
|
||||
1, 1,
|
||||
NULL, NULL, NULL, NULL,
|
||||
NULL, NULL,
|
||||
&config_weechat_debug_create_option, NULL,
|
||||
&config_weechat_debug_delete_option, NULL);
|
||||
if (!ptr_section)
|
||||
{
|
||||
config_file_free (weechat_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
weechat_config_section_debug = ptr_section;
|
||||
|
||||
/* startup */
|
||||
ptr_section = config_file_new_section (weechat_config_file, "startup",
|
||||
0, 0,
|
||||
|
||||
@@ -190,6 +190,10 @@ extern struct t_config_option *config_plugin_path;
|
||||
extern struct t_config_option *config_plugin_save_config_on_unload;
|
||||
|
||||
|
||||
extern struct t_config_option *config_weechat_debug_get (const char *plugin_name);
|
||||
extern int config_weechat_debug_set (const char *plugin_name,
|
||||
const char *value);
|
||||
extern void config_weechat_debug_set_all ();
|
||||
extern int config_weechat_init ();
|
||||
extern int config_weechat_read ();
|
||||
extern int config_weechat_reload ();
|
||||
|
||||
@@ -24,6 +24,7 @@ struct t_gui_window_tree;
|
||||
|
||||
extern void debug_dump (int crash);
|
||||
extern void debug_sigsegv ();
|
||||
extern void debug_windows_tree ();
|
||||
extern void debug_init ();
|
||||
|
||||
#endif /* wee-debug.h */
|
||||
|
||||
@@ -69,6 +69,7 @@
|
||||
#include "../plugins/plugin.h"
|
||||
|
||||
|
||||
int weechat_debug_core = 0; /* debug level for core */
|
||||
char *weechat_argv0 = NULL; /* WeeChat binary file name (argv[0])*/
|
||||
int weechat_upgrading; /* =1 if WeeChat is upgrading */
|
||||
time_t weechat_start_time; /* start time (used by /uptime cmd) */
|
||||
|
||||
@@ -98,6 +98,7 @@
|
||||
|
||||
/* global variables and functions */
|
||||
|
||||
extern int weechat_debug_core;
|
||||
extern char *weechat_argv0;
|
||||
extern time_t weechat_start_time;
|
||||
extern int weechat_quit;
|
||||
|
||||
@@ -50,10 +50,6 @@ IF(ENABLE_DEMO)
|
||||
ADD_SUBDIRECTORY( demo )
|
||||
ENDIF(ENABLE_DEMO)
|
||||
|
||||
IF(NOT DISABLE_DEBUG)
|
||||
ADD_SUBDIRECTORY( debug )
|
||||
ENDIF(NOT DISABLE_DEBUG)
|
||||
|
||||
IF(NOT DISABLE_FIFO)
|
||||
ADD_SUBDIRECTORY( fifo )
|
||||
ENDIF(NOT DISABLE_FIFO)
|
||||
|
||||
@@ -38,10 +38,6 @@ if PLUGIN_CHARSET
|
||||
charset_dir = charset
|
||||
endif
|
||||
|
||||
if PLUGIN_DEBUG
|
||||
debug_dir = debug
|
||||
endif
|
||||
|
||||
if PLUGIN_DEMO
|
||||
demo_dir = demo
|
||||
endif
|
||||
@@ -90,6 +86,6 @@ if PLUGIN_XFER
|
||||
xfer_dir = xfer
|
||||
endif
|
||||
|
||||
SUBDIRS = . $(alias_dir) $(aspell_dir) $(charset_dir) $(debug_dir) \
|
||||
$(demo_dir) $(fifo_dir) $(irc_dir) $(logger_dir) $(notify_dir) \
|
||||
$(script_dir) $(trigger_dir) $(xfer_dir)
|
||||
SUBDIRS = . $(alias_dir) $(aspell_dir) $(charset_dir) $(demo_dir) $(fifo_dir) \
|
||||
$(irc_dir) $(logger_dir) $(notify_dir) $(script_dir) \
|
||||
$(trigger_dir) $(xfer_dir)
|
||||
|
||||
@@ -132,7 +132,7 @@ weechat_aspell_speller_new (const char *lang)
|
||||
if (!lang)
|
||||
return NULL;
|
||||
|
||||
if (aspell_debug)
|
||||
if (weechat_aspell_plugin->debug)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
"%s: creating new speller for lang \"%s\"",
|
||||
@@ -194,7 +194,7 @@ weechat_aspell_speller_free (struct t_aspell_speller *speller)
|
||||
if (!speller)
|
||||
return;
|
||||
|
||||
if (aspell_debug)
|
||||
if (weechat_aspell_plugin->debug)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
"%s: removing speller for lang \"%s\"",
|
||||
|
||||
@@ -40,8 +40,6 @@ WEECHAT_PLUGIN_LICENSE("GPL3");
|
||||
|
||||
struct t_weechat_plugin *weechat_aspell_plugin = NULL;
|
||||
|
||||
int aspell_debug = 0;
|
||||
|
||||
char *aspell_last_modifier_string = NULL; /* last str. received by modifier */
|
||||
char *aspell_last_modifier_result = NULL; /* last str. built by modifier */
|
||||
|
||||
@@ -153,39 +151,6 @@ struct t_aspell_code countries_avail[] =
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* weechat_aspell_debug_cb: callback for "debug" signal
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_aspell_debug_cb (void *data, const char *signal, const char *type_data,
|
||||
void *signal_data)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) signal;
|
||||
|
||||
if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
|
||||
{
|
||||
if (weechat_strcasecmp ((char *)signal_data, ASPELL_PLUGIN_NAME) == 0)
|
||||
{
|
||||
aspell_debug ^= 1;
|
||||
if (aspell_debug)
|
||||
{
|
||||
weechat_printf (NULL, _("%s: debug enabled"),
|
||||
ASPELL_PLUGIN_NAME);
|
||||
}
|
||||
else
|
||||
{
|
||||
weechat_printf (NULL, _("%s: debug disabled"),
|
||||
ASPELL_PLUGIN_NAME);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_aspell_build_option_name: build option name with a buffer
|
||||
*/
|
||||
@@ -981,9 +946,6 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
if (weechat_aspell_config_read () < 0)
|
||||
return WEECHAT_RC_ERROR;
|
||||
|
||||
/* callback for debug */
|
||||
weechat_hook_signal ("debug", &weechat_aspell_debug_cb, NULL);
|
||||
|
||||
/* command /aspell */
|
||||
weechat_hook_command ("aspell",
|
||||
N_("aspell plugin configuration"),
|
||||
|
||||
@@ -31,8 +31,6 @@ struct t_aspell_code
|
||||
char *name;
|
||||
};
|
||||
|
||||
extern int aspell_debug;
|
||||
|
||||
extern struct t_weechat_plugin *weechat_aspell_plugin;
|
||||
|
||||
extern struct t_aspell_code langs_avail[];
|
||||
|
||||
@@ -53,41 +53,6 @@ struct t_config_section *charset_config_section_encode = NULL;
|
||||
char *charset_terminal = NULL;
|
||||
char *charset_internal = NULL;
|
||||
|
||||
int charset_debug = 0;
|
||||
|
||||
|
||||
/*
|
||||
* charset_debug_cb: callback for "debug" signal
|
||||
*/
|
||||
|
||||
int
|
||||
charset_debug_cb (void *data, const char *signal, const char *type_data,
|
||||
void *signal_data)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) signal;
|
||||
|
||||
if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
|
||||
{
|
||||
if (weechat_strcasecmp ((char *)signal_data, CHARSET_PLUGIN_NAME) == 0)
|
||||
{
|
||||
charset_debug ^= 1;
|
||||
if (charset_debug)
|
||||
{
|
||||
weechat_printf (NULL, _("%s: debug enabled"),
|
||||
CHARSET_PLUGIN_NAME);
|
||||
}
|
||||
else
|
||||
{
|
||||
weechat_printf (NULL, _("%s: debug disabled"),
|
||||
CHARSET_PLUGIN_NAME);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* charset_config_reaload: reload charset configuration file
|
||||
@@ -349,7 +314,7 @@ charset_decode_cb (void *data, const char *modifier, const char *modifier_data,
|
||||
|
||||
charset = charset_get (charset_config_section_decode, modifier_data,
|
||||
charset_default_decode);
|
||||
if (charset_debug)
|
||||
if (weechat_charset_plugin->debug)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
"charset: debug: using 'decode' charset: %s "
|
||||
@@ -378,7 +343,7 @@ charset_encode_cb (void *data, const char *modifier, const char *modifier_data,
|
||||
|
||||
charset = charset_get (charset_config_section_encode, modifier_data,
|
||||
charset_default_encode);
|
||||
if (charset_debug)
|
||||
if (weechat_charset_plugin->debug)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
"charset: debug: using 'encode' charset: %s "
|
||||
@@ -525,8 +490,6 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
|
||||
weechat_plugin = plugin;
|
||||
|
||||
charset_debug = weechat_config_boolean (weechat_config_get ("weechat.plugin.debug"));
|
||||
|
||||
/* get terminal & internal charsets */
|
||||
charset_terminal = weechat_info_get ("charset_terminal", "");
|
||||
charset_internal = weechat_info_get ("charset_internal", "");
|
||||
@@ -560,9 +523,6 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
weechat_hook_modifier ("charset_decode", &charset_decode_cb, NULL);
|
||||
weechat_hook_modifier ("charset_encode", &charset_encode_cb, NULL);
|
||||
|
||||
/* callback for debug */
|
||||
weechat_hook_signal ("debug", &charset_debug_cb, NULL);
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
# Copyright (c) 2003-2008 FlashCode <flashcode@flashtux.org>
|
||||
#
|
||||
# This program 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.
|
||||
#
|
||||
# This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
ADD_LIBRARY(debug MODULE debug.c)
|
||||
SET_TARGET_PROPERTIES(debug PROPERTIES PREFIX "")
|
||||
|
||||
TARGET_LINK_LIBRARIES(debug)
|
||||
|
||||
INSTALL(TARGETS debug LIBRARY DESTINATION lib/${PROJECT_NAME}/plugins)
|
||||
@@ -1,25 +0,0 @@
|
||||
# Copyright (c) 2003-2008 FlashCode <flashcode@flashtux.org>
|
||||
#
|
||||
# This program 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.
|
||||
#
|
||||
# This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
INCLUDES = -DLOCALEDIR=\"$(datadir)/locale\" $(DEBUG_CFLAGS)
|
||||
|
||||
libdir = ${weechat_libdir}/plugins
|
||||
|
||||
lib_LTLIBRARIES = debug.la
|
||||
|
||||
debug_la_SOURCES = debug.c
|
||||
debug_la_LDFLAGS = -module
|
||||
debug_la_LIBADD = $(DEBUG_LFLAGS)
|
||||
@@ -1,126 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2008 by FlashCode <flashcode@flashtux.org>
|
||||
* See README for License detail, AUTHORS for developers list.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* debug.c: Debug plugin for WeeChat */
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../weechat-plugin.h"
|
||||
|
||||
|
||||
#define DEBUG_PLUGIN_NAME "debug"
|
||||
|
||||
WEECHAT_PLUGIN_NAME(DEBUG_PLUGIN_NAME);
|
||||
WEECHAT_PLUGIN_DESCRIPTION("Debug plugin for WeeChat");
|
||||
WEECHAT_PLUGIN_AUTHOR("FlashCode <flashcode@flashtux.org>");
|
||||
WEECHAT_PLUGIN_VERSION(WEECHAT_VERSION);
|
||||
WEECHAT_PLUGIN_WEECHAT_VERSION(WEECHAT_VERSION);
|
||||
WEECHAT_PLUGIN_LICENSE("GPL3");
|
||||
|
||||
struct t_weechat_plugin *weechat_debug_plugin = NULL;
|
||||
#define weechat_plugin weechat_debug_plugin
|
||||
|
||||
|
||||
/*
|
||||
* debug_command_cb: callback for /debug command
|
||||
*/
|
||||
|
||||
int
|
||||
debug_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
char **argv, char **argv_eol)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) buffer;
|
||||
|
||||
if (argc >= 2)
|
||||
{
|
||||
if (weechat_strcasecmp (argv[1], "dump") == 0)
|
||||
{
|
||||
weechat_hook_signal_send ("debug_dump",
|
||||
WEECHAT_HOOK_SIGNAL_STRING, NULL);
|
||||
//debug_dump (0);
|
||||
}
|
||||
else if (weechat_strcasecmp (argv[1], "buffer") == 0)
|
||||
{
|
||||
weechat_hook_signal_send ("debug_buffer",
|
||||
WEECHAT_HOOK_SIGNAL_POINTER, buffer);
|
||||
/*gui_buffer_dump_hexa (buffer);
|
||||
gui_chat_printf (NULL,
|
||||
"DEBUG: buffer content written in WeeChat "
|
||||
"log file");
|
||||
*/
|
||||
}
|
||||
else if (weechat_strcasecmp (argv[1], "windows") == 0)
|
||||
{
|
||||
weechat_hook_signal_send ("debug_windows",
|
||||
WEECHAT_HOOK_SIGNAL_STRING, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
weechat_hook_signal_send ("debug",
|
||||
WEECHAT_HOOK_SIGNAL_STRING, argv_eol[1]);
|
||||
}
|
||||
}
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_plugin_init: initialize debug plugin
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
|
||||
weechat_plugin = plugin;
|
||||
|
||||
weechat_hook_command ("debug",
|
||||
N_("print debug messages"),
|
||||
N_("dump | buffer | windows | text"),
|
||||
N_(" dump: save memory dump in WeeChat log file (same "
|
||||
"dump is written when WeeChat crashes)\n"
|
||||
" buffer: dump buffer content with hexadecimal values "
|
||||
"in log file\n"
|
||||
"windows: display windows tree\n"
|
||||
" text: send \"debug\" signal with \"text\" as "
|
||||
"argument"),
|
||||
"dump|buffer|windows",
|
||||
&debug_command_cb, NULL);
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_plugin_end: end debug plugin
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_plugin_end (struct t_weechat_plugin *plugin)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) plugin;
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
+2
-34
@@ -43,35 +43,6 @@ WEECHAT_PLUGIN_LICENSE("GPL3");
|
||||
struct t_weechat_plugin *weechat_demo_plugin = NULL;
|
||||
#define weechat_plugin weechat_demo_plugin
|
||||
|
||||
int demo_debug = 0;
|
||||
|
||||
|
||||
/*
|
||||
* demo_debug_signal_debug_cb: callback for "debug" signal
|
||||
*/
|
||||
|
||||
int
|
||||
demo_debug_signal_debug_cb (void *data, const char *signal,
|
||||
const char *type_data, void *signal_data)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) signal;
|
||||
|
||||
if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
|
||||
{
|
||||
if (weechat_strcasecmp ((char *)signal_data, DEMO_PLUGIN_NAME) == 0)
|
||||
{
|
||||
demo_debug ^= 1;
|
||||
if (demo_debug)
|
||||
weechat_printf (NULL, _("%s: debug enabled"), DEMO_PLUGIN_NAME);
|
||||
else
|
||||
weechat_printf (NULL, _("%s: debug disabled"), DEMO_PLUGIN_NAME);
|
||||
}
|
||||
}
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* demo_printf_command_cb: demo command for printf
|
||||
@@ -139,7 +110,7 @@ demo_buffer_close_cb (void *data, struct t_gui_buffer *buffer)
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
if (demo_debug)
|
||||
if (weechat_demo_plugin->debug)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
"buffer_close_cb: buffer = %x (%s)",
|
||||
@@ -368,7 +339,7 @@ demo_signal_cb (void *data, const char *signal, const char *type_data,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
if (demo_debug)
|
||||
if (weechat_demo_plugin->debug)
|
||||
{
|
||||
if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
|
||||
{
|
||||
@@ -416,8 +387,6 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
|
||||
weechat_plugin = plugin;
|
||||
|
||||
demo_debug = weechat_config_boolean (weechat_config_get ("weechat.plugin.debug"));
|
||||
|
||||
weechat_hook_command ("demo_printf",
|
||||
N_("print some messages on current ubffer"),
|
||||
N_("[text]"),
|
||||
@@ -459,7 +428,6 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
"%I",
|
||||
&demo_infolist_command_cb, NULL);
|
||||
|
||||
weechat_hook_signal ("debug", &demo_debug_signal_debug_cb, NULL);
|
||||
weechat_hook_signal ("*", &demo_signal_cb, NULL);
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include "irc-server.h"
|
||||
|
||||
|
||||
int irc_debug = 0;
|
||||
struct t_gui_buffer *irc_debug_buffer = NULL;
|
||||
|
||||
|
||||
@@ -58,7 +57,7 @@ irc_debug_printf (struct t_irc_server *server, int send, int modified,
|
||||
{
|
||||
char *buf;
|
||||
|
||||
if (!irc_debug || !message)
|
||||
if (!weechat_irc_plugin->debug || !message)
|
||||
return;
|
||||
|
||||
if (!irc_debug_buffer)
|
||||
@@ -100,33 +99,6 @@ irc_debug_printf (struct t_irc_server *server, int send, int modified,
|
||||
free (buf);
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_debug_signal_debug_cb: callback for "debug" signal
|
||||
*/
|
||||
|
||||
int
|
||||
irc_debug_signal_debug_cb (void *data, const char *signal,
|
||||
const char *type_data, void *signal_data)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) signal;
|
||||
|
||||
if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
|
||||
{
|
||||
if (weechat_strcasecmp ((char *)signal_data, IRC_PLUGIN_NAME) == 0)
|
||||
{
|
||||
irc_debug ^= 1;
|
||||
if (irc_debug)
|
||||
weechat_printf (NULL, _("%s: debug enabled"), IRC_PLUGIN_NAME);
|
||||
else
|
||||
weechat_printf (NULL, _("%s: debug disabled"), IRC_PLUGIN_NAME);
|
||||
}
|
||||
}
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_debug_signal_debug_dump_cb: dump IRC data in WeeChat log file
|
||||
*/
|
||||
@@ -161,7 +133,5 @@ irc_debug_signal_debug_dump_cb (void *data, const char *signal,
|
||||
void
|
||||
irc_debug_init ()
|
||||
{
|
||||
irc_debug = weechat_config_boolean (weechat_config_get ("weechat.plugin.debug"));
|
||||
weechat_hook_signal ("debug", &irc_debug_signal_debug_cb, NULL);
|
||||
weechat_hook_signal ("debug_dump", &irc_debug_signal_debug_dump_cb, NULL);
|
||||
}
|
||||
|
||||
@@ -828,7 +828,7 @@ irc_server_new (const char *name, int autoconnect, int autoreconnect,
|
||||
if (!name || !addresses)
|
||||
return NULL;
|
||||
|
||||
if (irc_debug)
|
||||
if (weechat_irc_plugin->debug)
|
||||
{
|
||||
weechat_log_printf ("Creating new server (name:%s, addresses:%s, "
|
||||
"pwd:%s, nicks:%s, username:%s, realname:%s, "
|
||||
|
||||
@@ -68,6 +68,4 @@
|
||||
extern struct t_weechat_plugin *weechat_irc_plugin;
|
||||
extern struct t_hook *irc_hook_timer_check_away;
|
||||
|
||||
extern int irc_debug;
|
||||
|
||||
#endif /* irc.h */
|
||||
|
||||
@@ -73,7 +73,7 @@ logger_buffer_add (struct t_gui_buffer *buffer, int log_level)
|
||||
if (!buffer)
|
||||
return NULL;
|
||||
|
||||
if (logger_debug)
|
||||
if (weechat_logger_plugin->debug)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
"%s: start logging for buffer \"%s\"",
|
||||
@@ -157,7 +157,7 @@ logger_buffer_free (struct t_logger_buffer *logger_buffer)
|
||||
{
|
||||
struct t_logger_buffer *new_logger_buffers;
|
||||
|
||||
if (logger_debug)
|
||||
if (weechat_logger_plugin->debug)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
"%s: stop logging for buffer \"%s\"",
|
||||
|
||||
@@ -52,44 +52,9 @@ WEECHAT_PLUGIN_LICENSE("GPL3");
|
||||
|
||||
struct t_weechat_plugin *weechat_logger_plugin = NULL;
|
||||
|
||||
int logger_debug = 0;
|
||||
|
||||
char *logger_buf_write = NULL; /* buffer for writing a line */
|
||||
|
||||
|
||||
/*
|
||||
* logger_debug_cb: callback for "debug" signal
|
||||
*/
|
||||
|
||||
int
|
||||
logger_debug_cb (void *data, const char *signal, const char *type_data,
|
||||
void *signal_data)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) signal;
|
||||
|
||||
if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
|
||||
{
|
||||
if (weechat_strcasecmp ((char *)signal_data, LOGGER_PLUGIN_NAME) == 0)
|
||||
{
|
||||
logger_debug ^= 1;
|
||||
if (logger_debug)
|
||||
{
|
||||
weechat_printf (NULL, _("%s: debug enabled"),
|
||||
LOGGER_PLUGIN_NAME);
|
||||
}
|
||||
else
|
||||
{
|
||||
weechat_printf (NULL, _("%s: debug disabled"),
|
||||
LOGGER_PLUGIN_NAME);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* logger_create_directory: create logger directory
|
||||
* return 1 if success (directory created or already
|
||||
@@ -293,7 +258,7 @@ logger_get_filename (struct t_gui_buffer *buffer)
|
||||
if (!mask_decoded)
|
||||
return NULL;
|
||||
|
||||
if (logger_debug)
|
||||
if (weechat_logger_plugin->debug)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
"%s: buffer = \"%s\", mask = \"%s\", "
|
||||
@@ -963,9 +928,6 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
if (logger_config_read () < 0)
|
||||
return WEECHAT_RC_ERROR;
|
||||
|
||||
/* callback for debug */
|
||||
weechat_hook_signal ("debug", &logger_debug_cb, NULL);
|
||||
|
||||
/* command /logger */
|
||||
weechat_hook_command ("logger",
|
||||
N_("logger plugin configuration"),
|
||||
|
||||
@@ -26,8 +26,6 @@
|
||||
#define LOGGER_BUF_WRITE_SIZE (16*1024)
|
||||
#define LOGGER_LEVEL_DEFAULT 9
|
||||
|
||||
extern int logger_debug;
|
||||
|
||||
extern struct t_weechat_plugin *weechat_logger_plugin;
|
||||
|
||||
extern void logger_start_buffer_all ();
|
||||
|
||||
@@ -49,8 +49,6 @@ struct t_config_section *notify_config_section_buffer = NULL;
|
||||
char *notify_string[NOTIFY_NUM_LEVELS] =
|
||||
{ "none", "highlight", "message", "all" };
|
||||
|
||||
int notify_debug = 0;
|
||||
|
||||
|
||||
/*
|
||||
* notify_search: search a notify level by name
|
||||
@@ -94,33 +92,6 @@ notify_build_option_name (struct t_gui_buffer *buffer)
|
||||
return option_name;
|
||||
}
|
||||
|
||||
/*
|
||||
* notify_debug_cb: callback for "debug" signal
|
||||
*/
|
||||
|
||||
int
|
||||
notify_debug_cb (void *data, const char *signal, const char *type_data,
|
||||
void *signal_data)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) signal;
|
||||
|
||||
if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
|
||||
{
|
||||
if (weechat_strcasecmp ((char *)signal_data, NOTIFY_PLUGIN_NAME) == 0)
|
||||
{
|
||||
notify_debug ^= 1;
|
||||
if (notify_debug)
|
||||
weechat_printf (NULL, _("%s: debug enabled"), NOTIFY_PLUGIN_NAME);
|
||||
else
|
||||
weechat_printf (NULL, _("%s: debug disabled"), NOTIFY_PLUGIN_NAME);
|
||||
}
|
||||
}
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* notify_get: read a notify level in config file
|
||||
* we first try with all arguments, then remove one by one
|
||||
@@ -183,7 +154,7 @@ notify_set_buffer (struct t_gui_buffer *buffer)
|
||||
if (option_name)
|
||||
{
|
||||
notify = notify_get (option_name);
|
||||
if (notify_debug)
|
||||
if (weechat_notify_plugin->debug)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
_("notify: debug: set notify for buffer %s to "
|
||||
@@ -479,8 +450,6 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
|
||||
weechat_plugin = plugin;
|
||||
|
||||
notify_debug = weechat_config_boolean (weechat_config_get ("weechat.plugin.debug"));
|
||||
|
||||
if (!notify_config_init ())
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -511,9 +480,6 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
/* callback when a config option is changed */
|
||||
weechat_hook_config ("notify.buffer.*", ¬ify_config_cb, NULL);
|
||||
|
||||
/* callback for debug */
|
||||
weechat_hook_signal ("debug", ¬ify_debug_cb, NULL);
|
||||
|
||||
/* set notify for open buffers */
|
||||
notify_set_buffer_all ();
|
||||
|
||||
|
||||
@@ -138,6 +138,7 @@ plugin_load (const char *filename)
|
||||
int rc, i, argc;
|
||||
char **argv;
|
||||
struct t_weechat_plugin *new_plugin;
|
||||
struct t_config_option *ptr_option;
|
||||
|
||||
if (!filename)
|
||||
return NULL;
|
||||
@@ -316,6 +317,8 @@ plugin_load (const char *filename)
|
||||
new_plugin->weechat_version = strdup (weechat_version);
|
||||
new_plugin->license = strdup (license);
|
||||
new_plugin->charset = (charset) ? strdup (charset) : NULL;
|
||||
ptr_option = config_weechat_debug_get (name);
|
||||
new_plugin->debug = (ptr_option) ? CONFIG_INTEGER(ptr_option) : 0;
|
||||
|
||||
/* functions */
|
||||
new_plugin->plugin_get_name = &plugin_get_name;
|
||||
@@ -923,6 +926,8 @@ plugin_add_to_infolist (struct t_infolist *infolist,
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "charset", plugin->charset))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "debug", plugin->debug))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -947,6 +952,7 @@ plugin_print_log ()
|
||||
log_printf (" description. . . . . . : '%s'", ptr_plugin->description);
|
||||
log_printf (" version. . . . . . . . : '%s'", ptr_plugin->version);
|
||||
log_printf (" charset. . . . . . . . : '%s'", ptr_plugin->charset);
|
||||
log_printf (" debug. . . . . . . . . : %d", ptr_plugin->debug);
|
||||
log_printf (" prev_plugin. . . . . . : 0x%x", ptr_plugin->prev_plugin);
|
||||
log_printf (" next_plugin. . . . . . : 0x%x", ptr_plugin->next_plugin);
|
||||
}
|
||||
|
||||
@@ -111,6 +111,7 @@ struct t_weechat_plugin
|
||||
char *weechat_version; /* weechat version required */
|
||||
char *license; /* license */
|
||||
char *charset; /* charset used by plugin */
|
||||
int debug; /* debug level for plugin (0=off) */
|
||||
struct t_weechat_plugin *prev_plugin; /* link to previous plugin */
|
||||
struct t_weechat_plugin *next_plugin; /* link to next plugin */
|
||||
|
||||
|
||||
@@ -70,8 +70,6 @@ struct t_xfer *xfer_list = NULL; /* list of files/chats */
|
||||
struct t_xfer *last_xfer = NULL; /* last file/chat in list */
|
||||
int xfer_count = 0; /* number of xfer */
|
||||
|
||||
int xfer_debug = 0;
|
||||
|
||||
int xfer_signal_upgrade_received = 0; /* signal "upgrade" received ? */
|
||||
|
||||
|
||||
@@ -1366,8 +1364,6 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
(void) argv;
|
||||
|
||||
weechat_plugin = plugin;
|
||||
|
||||
xfer_debug = weechat_config_boolean (weechat_config_get ("weechat.plugin.debug"));
|
||||
|
||||
if (!xfer_config_init ())
|
||||
return WEECHAT_RC_ERROR;
|
||||
|
||||
@@ -153,7 +153,6 @@ extern char *xfer_protocol_string[];
|
||||
extern char *xfer_status_string[];
|
||||
extern struct t_xfer *xfer_list, *last_xfer;
|
||||
extern int xfer_count;
|
||||
extern int xfer_debug;
|
||||
|
||||
extern int xfer_valid (struct t_xfer *xfer);
|
||||
extern struct t_xfer *xfer_search_by_number (int number);
|
||||
|
||||
Reference in New Issue
Block a user