Index: src/vortex_handlers.h =================================================================== --- src/vortex_handlers.h (revision 3194) +++ src/vortex_handlers.h (working copy) @@ -1571,6 +1571,25 @@ */ typedef void (*VortexOnClosedChannel) (VortexChannel * channel, axlPointer user_data); + +/** + * @brief Handler definition that allows a client to print log messages itself. + * + * This function is used by: + * + * - \ref vortex_log_set_logger + * - \ref vortex_log_get_logger + * + * @param domain The domain where the log was produced. + * @param log_level The level of the log + * @param message The message + * @param args Arguments for the message. + */ +typedef void (*VortexLogHandler) (const char * domain, + VortexDebugLevel log_level, + const char * message, + va_list args); + #endif /* @} */ Index: src/vortex_types.h =================================================================== --- src/vortex_types.h (revision 3194) +++ src/vortex_types.h (working copy) @@ -884,6 +884,27 @@ }VortexTunnelItem; +/* + * @brief Debug levels of logging messages printed by Vortex. + * Used with \ref VortexLogHandler, a callback which lets the client + * print logging messages itself. + */ +typedef enum { + /** + * @brief A debugging message; describes normal operation, not a problem. + */ + VORTEX_LEVEL_DEBUG, + /** + * @brief A warning message; describes a possible problem. + */ + VORTEX_LEVEL_WARNING, + /** + * @brief A critical message; describes a definite problem. + */ + VORTEX_LEVEL_CRITICAL +} VortexDebugLevel; + + #endif /* @} */ Index: src/vortex.c =================================================================== --- src/vortex.c (revision 3194) +++ src/vortex.c (working copy) @@ -323,6 +323,26 @@ return ctx->use_log_mutex; } +void vortex_log_set_handler (VortexLogHandler handler) +{ + /* get current context */ + VortexCtx * ctx = vortex_ctx_get (); + v_return_if_fail (ctx); + + /* configure status */ + ctx->debug_handler = handler; +} + +VortexLogHandler vortex_log_get_handler () +{ + /* get current context */ + VortexCtx * ctx = vortex_ctx_get (); + v_return_val_if_fail (ctx, NULL); + + /* configure status */ + return ctx->debug_handler; +} + /** * @brief Allows to get a vortex configuration, providing a valid * vortex item. @@ -562,6 +582,12 @@ if (use_log_mutex) vortex_mutex_lock(&ctx->log_mutex); + if( ctx->debug_handler ) { + /* call a custom debug handler if one has been set */ + ctx->debug_handler(domain,log_level,message,args); + } else { + /* ...otherwise print the message normally: */ + /* printout the process pid */ #if defined (__GNUC__) if (vortex_color_log_is_enabled ()) @@ -611,6 +637,7 @@ /* ensure that the log is droped to the console */ fflush (stdout); + } /* release the mutex only if configured */ if (use_log_mutex) Index: src/vortex.h =================================================================== --- src/vortex.h (revision 3194) +++ src/vortex.h (working copy) @@ -311,6 +311,10 @@ bool vortex_log_is_enabled_acquire_mutex (); +void vortex_log_set_handler (VortexLogHandler handler); + +VortexLogHandler vortex_log_get_handler (); + void vortex_writer_data_free (VortexWriterData * writer_data); /** @@ -392,8 +396,7 @@ const char * str_value); /* - * @internal Debug levels to be used with \ref _vortex_log, which is used - * through vortex_log macro. + * @internal used through vortex_log macro. * * @param domain Domain that is registering a log. * @@ -401,21 +404,6 @@ * * @param message Message that is being registered. */ -typedef enum { - /** - * @internal Log a message as a debug message. - */ - VORTEX_LEVEL_DEBUG, - /** - * @internal Log a warning message. - */ - VORTEX_LEVEL_WARNING, - /** - * @internal Log a critical message. - */ - VORTEX_LEVEL_CRITICAL -} VortexDebugLevel; - void _vortex_log (const char * domain, VortexDebugLevel level, const char * message, Index: src/vortex_ctx_private.h =================================================================== --- src/vortex_ctx_private.h (revision 3194) +++ src/vortex_ctx_private.h (working copy) @@ -74,6 +74,8 @@ bool debug_color_checked; bool debug_color; + VortexLogHandler debug_handler; + #if defined(AXL_OS_WIN32) /** * Temporal hack to support sock limits under windows until we