/* SetLogging */ static rc_t KDylibSetLogging ( const KDylib *self ) { rc_t ( CC * set_formatter ) ( KFmtWriter writer, KLogFmtFlags flags, void *data ); rc_t ( CC * set_writer ) ( KWrtWriter writer, void *data ); /* set the current logging level */ rc_t ( CC * set_level ) ( KLogLevel lvl ) = ( void* ) GetProcAddress ( self -> handle, "KLogLevelSet" ); if ( set_level != NULL ) { KLogLevel lvl = KLogLevelGet (); ( * set_level ) ( lvl ); } /* determine current library logging */ set_writer = ( void* ) GetProcAddress ( self -> handle, "KOutHandlerSet" ); if ( set_writer != NULL ) { const KWrtHandler* handler = KOutHandlerGet (); ( * set_writer ) ( handler -> writer, handler -> data ); } set_formatter = ( void* ) GetProcAddress ( self -> handle, "KLogLibFmtHandlerSet" ); if ( set_formatter != NULL ) { KLogFmtFlags flags = KLogLibFmtFlagsGet (); const KFmtHandler* fmt_handler = KLogFmtHandlerGet (); ( * set_formatter ) ( fmt_handler -> formatter, flags, fmt_handler -> data ); } set_writer = ( void* ) GetProcAddress ( self -> handle, "KLogLibHandlerSet" ); if ( set_writer != NULL ) { const KWrtHandler* handler = KLogLibHandlerGet (); ( * set_writer ) ( handler -> writer, handler -> data ); } set_formatter = ( void* ) GetProcAddress ( self -> handle, "KStsLibFmtHandlerSet" ); if ( set_formatter != NULL ) { KStsFmtFlags flags = KStsLibFmtFlagsGet (); const KFmtHandler* fmt_handler = KStsFmtHandlerGet (); ( * set_formatter ) ( fmt_handler -> formatter, flags, fmt_handler -> data ); } set_writer = ( void* ) GetProcAddress ( self -> handle, "KStsLibHandlerSet" ); if ( set_writer != NULL ) { const KWrtHandler* handler = KStsLibHandlerGet (); ( * set_writer ) ( handler -> writer, handler -> data ); } #if _DEBUGGING set_writer = ( void* ) GetProcAddress ( self -> handle, "KDbgHandlerSet" ); if ( set_writer != NULL ) { const KWrtHandler* handler = KDbgHandlerGet (); ( * set_writer ) ( handler -> writer, handler -> data ); } #endif return 0; }
LIB_EXPORT rc_t CC KStsLibMsg(const char* msg, ...) { rc_t rc; va_list args; va_start(args, msg); rc = sts_print(KStsLibFmtHandlerGet(), G_sts_lib_formatter_flags, KStsLibHandlerGet(), msg, args); va_end(args); return rc; }
LIB_EXPORT KWrtWriter CC KStsLibWriterGet ( void ) { return ( KStsLibHandlerGet()->writer ); }
LIB_EXPORT void * CC KStsLibDataGet ( void ) { return ( KStsLibHandlerGet()->data ); }