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:
parent
2352e5a0dd
commit
afda1d7b9d
@ -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_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.
|
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);
|
cmdh = (struct plugin_command_handle*) list_get_first(data->commands);
|
||||||
while (cmdh)
|
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()
|
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));
|
struct plugin_callback_data* data = (struct plugin_callback_data*) hub_malloc_zero(sizeof(struct plugin_callback_data));
|
||||||
data->commands = list_create();
|
data->commands = list_create();
|
||||||
return data;
|
return data;
|
||||||
@ -66,6 +67,7 @@ struct plugin_callback_data* plugin_callback_data_create()
|
|||||||
|
|
||||||
void plugin_callback_data_destroy(struct plugin_callback_data* data)
|
void plugin_callback_data_destroy(struct plugin_callback_data* data)
|
||||||
{
|
{
|
||||||
|
LOG_PLUGIN("plugin_callback_data_destroy()");
|
||||||
if (data->commands)
|
if (data->commands)
|
||||||
{
|
{
|
||||||
uhub_assert(list_size(data->commands) == 0);
|
uhub_assert(list_size(data->commands) == 0);
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#include "uhub.h"
|
#include "uhub.h"
|
||||||
#include "plugin_api/handle.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) \
|
#define INVOKE(HUB, FUNCNAME, CODE) \
|
||||||
|
@ -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_open(const char* filename)
|
||||||
{
|
{
|
||||||
struct uhub_plugin* plugin;
|
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));
|
plugin = (struct uhub_plugin*) hub_malloc_zero(sizeof(struct uhub_plugin));
|
||||||
if (!plugin)
|
if (!plugin)
|
||||||
@ -74,8 +74,9 @@ struct uhub_plugin* plugin_open(const char* filename)
|
|||||||
|
|
||||||
void plugin_close(struct uhub_plugin* plugin)
|
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);
|
hub_free(plugin->internals);
|
||||||
|
|
||||||
#ifdef HAVE_DLOPEN
|
#ifdef HAVE_DLOPEN
|
||||||
dlclose(plugin->handle);
|
dlclose(plugin->handle);
|
||||||
#else
|
#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))
|
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_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;
|
return handle;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -193,7 +194,7 @@ static int plugin_parse_line(char* line, int line_count, void* ptr_data)
|
|||||||
if (!params)
|
if (!params)
|
||||||
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);
|
plugin = plugin_load(soname, params, hub);
|
||||||
if (plugin)
|
if (plugin)
|
||||||
{
|
{
|
||||||
|
@ -51,6 +51,7 @@ static const char* prefixes[] =
|
|||||||
"DUMP",
|
"DUMP",
|
||||||
"MEM",
|
"MEM",
|
||||||
"PROTO",
|
"PROTO",
|
||||||
|
"PLUGIN",
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -185,12 +186,12 @@ void hub_log(int log_verbosity, const char *format, ...)
|
|||||||
|
|
||||||
if (logfile)
|
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);
|
fflush(logfile);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s %5s: %s\n", timestamp, prefixes[log_verbosity], logmsg);
|
fprintf(stderr, "%s %6s: %s\n", timestamp, prefixes[log_verbosity], logmsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@ enum log_verbosity {
|
|||||||
log_dump = 7,
|
log_dump = 7,
|
||||||
log_memory = 8,
|
log_memory = 8,
|
||||||
log_protocol = 9,
|
log_protocol = 9,
|
||||||
|
log_plugin = 10,
|
||||||
};
|
};
|
||||||
|
|
||||||
#define LOG_FATAL(format, ...) hub_log(log_fatal, format, ## __VA_ARGS__)
|
#define LOG_FATAL(format, ...) hub_log(log_fatal, format, ## __VA_ARGS__)
|
||||||
@ -42,9 +43,11 @@ enum log_verbosity {
|
|||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
# define LOG_DEBUG(format, ...) hub_log(log_debug, format, ## __VA_ARGS__)
|
# define LOG_DEBUG(format, ...) hub_log(log_debug, format, ## __VA_ARGS__)
|
||||||
# define LOG_TRACE(format, ...) hub_log(log_trace, 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
|
#else
|
||||||
# define LOG_DEBUG(format, ...) do { } while(0)
|
# define LOG_DEBUG(format, ...) do { } while(0)
|
||||||
# define LOG_TRACE(format, ...) do { } while(0)
|
# define LOG_TRACE(format, ...) do { } while(0)
|
||||||
|
# define LOG_PLUGIN(format, ...) do { } while(0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef LOWLEVEL_DEBUG
|
#ifdef LOWLEVEL_DEBUG
|
||||||
|
Loading…
Reference in New Issue
Block a user