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

Make message level available to message handler callback.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.