diff --git a/src/core/plugincallback.c b/src/core/plugincallback.c index 22aa57f..bf7aa46 100644 --- a/src/core/plugincallback.c +++ b/src/core/plugincallback.c @@ -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); diff --git a/src/core/plugininvoke.c b/src/core/plugininvoke.c index 77b410a..773fba0 100644 --- a/src/core/plugininvoke.c +++ b/src/core/plugininvoke.c @@ -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) \ diff --git a/src/core/pluginloader.c b/src/core/pluginloader.c index 8411c10..8e72fa7 100644 --- a/src/core/pluginloader.c +++ b/src/core/pluginloader.c @@ -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) { diff --git a/src/util/log.c b/src/util/log.c index edf11f7..42badb3 100644 --- a/src/util/log.c +++ b/src/util/log.c @@ -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); } } diff --git a/src/util/log.h b/src/util/log.h index a436fd1..1fcd42e 100644 --- a/src/util/log.h +++ b/src/util/log.h @@ -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