Navigation


Changeset 784:e87d083d0342 in freeDiameter for libfdproto


Ignore:
Timestamp:
Mar 30, 2012, 4:19:33 AM (12 years ago)
Author:
Sebastien Decugis <sdecugis@nict.go.jp>
Branch:
default
Phase:
public
Message:

Added ability to register another log function; thanks to Zack for the code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libfdproto/log.c

    r740 r784  
    5050int fd_breakhere(void) { return ++fd_breaks; }
    5151
     52/* Allow passing of the log and debug information from base stack to extensions */
     53void (*fd_external_logger)( const char * format, va_list *args ) = NULL;
     54
     55/* Register an dexternal call back for tracing and debug */
     56int fd_log_handler_register( void (*logger)(const char * format, va_list *args))
     57{
     58        CHECK_PARAMS( logger );
     59
     60        if ( fd_external_logger != NULL )
     61        {
     62               return EALREADY; /* only one registeration allowed */
     63        }
     64        else
     65        {
     66               fd_external_logger = logger;
     67        }
     68        return 0;
     69}
     70
     71/* Implement a simple reset function here */
     72int fd_log_handler_unregister ( void )
     73{
     74        fd_external_logger = NULL;
     75        return 0; /* Successfull in all cases. */
     76}
     77
    5278static void fd_cleanup_mutex_silent( void * mutex )
    5379{
     
    6591       
    6692        va_start(ap, format);
    67         vfprintf( fstr ?: stdout, format, ap);
     93        if ( fd_external_logger != NULL )
     94        {
     95               fd_external_logger( format, &ap );
     96        }
     97        else
     98        {
     99               vfprintf( fstr ?: stdout, format, ap);
     100               fflush(fstr ?: stdout);
     101        }
    68102        va_end(ap);
    69         fflush(fstr ?: stdout);
    70103
    71104        pthread_cleanup_pop(0);
Note: See TracChangeset for help on using the changeset viewer.