Added a LOG_PLUGIN macro for plugin output debug messages.

Converted all TRACE messages related to plugins to LOG_PLUGIN.
This commit is contained in:
Jan Vidar Krey 2011-12-09 16:36:14 +01:00
parent 2352e5a0dd
commit afda1d7b9d
5 changed files with 15 additions and 8 deletions

View File

@ -41,7 +41,7 @@ static int plugin_command_dispatch(struct command_base* cbase, struct hub_user*
struct plugin_user* puser = (struct plugin_user*) user; // FIXME: Use a proper conversion function instead.
struct plugin_command* pcommand = (struct plugin_command*) cmd; // FIXME: Use a proper conversion function instead.
LOG_INFO("plugin_command_dispatch: cmd=%s", cmd->prefix);
LOG_PLUGIN("plugin_command_dispatch: cmd=%s", cmd->prefix);
cmdh = (struct plugin_command_handle*) list_get_first(data->commands);
while (cmdh)
@ -59,6 +59,7 @@ static int plugin_command_dispatch(struct command_base* cbase, struct hub_user*
struct plugin_callback_data* plugin_callback_data_create()
{
LOG_PLUGIN("plugin_callback_data_create()");
struct plugin_callback_data* data = (struct plugin_callback_data*) hub_malloc_zero(sizeof(struct plugin_callback_data));
data->commands = list_create();
return data;
@ -66,6 +67,7 @@ struct plugin_callback_data* plugin_callback_data_create()
void plugin_callback_data_destroy(struct plugin_callback_data* data)
{
LOG_PLUGIN("plugin_callback_data_destroy()");
if (data->commands)
{
uhub_assert(list_size(data->commands) == 0);

View File

@ -20,7 +20,7 @@
#include "uhub.h"
#include "plugin_api/handle.h"
#define PLUGIN_DEBUG(hub, name) printf("Invoke %s on %d plugins\n",name, (int) (hub->plugins ? list_size(hub->plugins->loaded) : -1));
#define PLUGIN_DEBUG(hub, name) LOG_PLUGIN("Invoke %s on %d plugins", name, (int) (hub->plugins ? list_size(hub->plugins->loaded) : -1));
#define INVOKE(HUB, FUNCNAME, CODE) \

View File

@ -42,7 +42,7 @@ static struct plugin_hub_internals* get_internals(struct plugin_handle* handle)
struct uhub_plugin* plugin_open(const char* filename)
{
struct uhub_plugin* plugin;
LOG_TRACE("plugin_open: \"%s\"", filename);
LOG_PLUGIN("plugin_open: \"%s\"", filename);
plugin = (struct uhub_plugin*) hub_malloc_zero(sizeof(struct uhub_plugin));
if (!plugin)
@ -74,8 +74,9 @@ struct uhub_plugin* plugin_open(const char* filename)
void plugin_close(struct uhub_plugin* plugin)
{
LOG_TRACE("plugin_close: \"%s\"", plugin->filename);
LOG_PLUGIN("plugin_close: \"%s\"", plugin->filename);
hub_free(plugin->internals);
#ifdef HAVE_DLOPEN
dlclose(plugin->handle);
#else
@ -136,7 +137,7 @@ struct plugin_handle* plugin_load(const char* filename, const char* config, stru
if (handle->plugin_api_version == PLUGIN_API_VERSION && handle->plugin_funcs_size == sizeof(struct plugin_funcs))
{
LOG_INFO("Loaded plugin: %s: %s, version %s.", filename, handle->name, handle->version);
LOG_TRACE("Plugin API version: %d (func table size: " PRINTF_SIZE_T ")", handle->plugin_api_version, handle->plugin_funcs_size);
LOG_PLUGIN("Plugin API version: %d (func table size: " PRINTF_SIZE_T ")", handle->plugin_api_version, handle->plugin_funcs_size);
return handle;
}
else
@ -193,7 +194,7 @@ static int plugin_parse_line(char* line, int line_count, void* ptr_data)
if (!params)
params = "";
LOG_TRACE("Load plugin: \"%s\", params=\"%s\"", soname, params);
LOG_PLUGIN("Load plugin: \"%s\", params=\"%s\"", soname, params);
plugin = plugin_load(soname, params, hub);
if (plugin)
{

View File

@ -51,6 +51,7 @@ static const char* prefixes[] =
"DUMP",
"MEM",
"PROTO",
"PLUGIN",
0
};
@ -185,12 +186,12 @@ void hub_log(int log_verbosity, const char *format, ...)
if (logfile)
{
fprintf(logfile, "%s %5s: %s\n", timestamp, prefixes[log_verbosity], logmsg);
fprintf(logfile, "%s %6s: %s\n", timestamp, prefixes[log_verbosity], logmsg);
fflush(logfile);
}
else
{
fprintf(stderr, "%s %5s: %s\n", timestamp, prefixes[log_verbosity], logmsg);
fprintf(stderr, "%s %6s: %s\n", timestamp, prefixes[log_verbosity], logmsg);
}
}

View File

@ -31,6 +31,7 @@ enum log_verbosity {
log_dump = 7,
log_memory = 8,
log_protocol = 9,
log_plugin = 10,
};
#define LOG_FATAL(format, ...) hub_log(log_fatal, format, ## __VA_ARGS__)
@ -42,9 +43,11 @@ enum log_verbosity {
#ifdef DEBUG
# define LOG_DEBUG(format, ...) hub_log(log_debug, format, ## __VA_ARGS__)
# define LOG_TRACE(format, ...) hub_log(log_trace, format, ## __VA_ARGS__)
# define LOG_PLUGIN(format, ...) hub_log(log_plugin, format, ## __VA_ARGS__)
#else
# define LOG_DEBUG(format, ...) do { } while(0)
# define LOG_TRACE(format, ...) do { } while(0)
# define LOG_PLUGIN(format, ...) do { } while(0)
#endif
#ifdef LOWLEVEL_DEBUG