Changeset 803


Ignore:
Timestamp:
Aug 20, 2006, 10:45:04 PM (15 years ago)
Author:
joshe
Message:

Make message level available to message handler callback.

Location:
trunk/libtransmission
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/transmission.h

    r798 r803  
    6767 * function must be reentrant, it may be called from different threads.
    6868 * A NULL argument means to print messages to stderr.  The function's
    69  * prototype should look like this: void myErrFunc( const char * );
    70  **********************************************************************/
    71 void tr_setMessageFunction( void (*func)( const char * ) );
     69 * prototype should look like this: void myMsgFunc( int, const char * );
     70 **********************************************************************/
     71void tr_setMessageFunction( void (*func)( int, const char * ) );
    7272
    7373/***********************************************************************
     
    7878#define TR_MSG_ERR 1
    7979#define TR_MSG_INF 2
    80 #define TR_MSG_DBG 4
     80#define TR_MSG_DBG 3
    8181void tr_setMessageLevel( int );
    8282int tr_getMessageLevel( void );
  • trunk/libtransmission/utils.c

    r798 r803  
    2525#include "transmission.h"
    2626
    27 static void (*messageFunc)( const char * );
     27static void (*messageFunc)( int, const char * );
    2828
    2929static int verboseLevel = 0;
    3030
    31 void tr_setMessageFunction( void (*func)( const char * ) )
     31void tr_setMessageFunction( void (*func)( int, const char * ) )
    3232{
    3333    messageFunc = func;
     
    3636void tr_setMessageLevel( int level )
    3737{
    38     verboseLevel = level;
     38    verboseLevel = MAX( 0, level );
    3939}
    4040
     
    5353        char * env;
    5454        env          = getenv( "TR_DEBUG" );
    55         verboseLevel = env ? atoi( env ) : -1;
    56         verboseLevel = verboseLevel ? verboseLevel : -1;
     55        verboseLevel = ( env ? atoi( env ) : 0 ) + 1;
     56        verboseLevel = MAX( 1, verboseLevel );
    5757    }
    5858
    59     if( verboseLevel < 1 && level > TR_MSG_ERR )
    60     {
    61         return;
    62     }
    63     if( verboseLevel < 2 && level > TR_MSG_INF )
     59    if( verboseLevel < level )
    6460    {
    6561        return;
     
    7672    else
    7773    {
    78         messageFunc( string );
     74        messageFunc( level, string );
    7975    }
    8076}
Note: See TracChangeset for help on using the changeset viewer.