diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 4f91e15461..8379683e76 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,23 @@ +Mon Nov 29 12:45:05 1999 Gonzalo A. Diethelm + + * include/hbtrace.h: + * source/common/hbtrace.c: + * source/rtl/trace.c: + * doc/tracing.txt: + Modified the run-time trace interface functions, to simplify this + interface. Now there are just two C functions: + + current_state = hb_tracestate(new_state); + current_level = hb_tracelevel(new_level); + + and just two Clipper functions: + + current_state := HB_TRACESTATE( [new_state] ) + current_level := HB_TRACELEVEL( [new_level] ) + + Both check their argument, so passing a -1 to any of them will + return the appropriate current setting without modifying it. + 19991128-22:24 GMT+1 Victor Szel * source/rtl/asort.prg source/rtl/browdb.prg diff --git a/harbour/doc/tracing.txt b/harbour/doc/tracing.txt index 179463e222..f39a1d2ac2 100644 --- a/harbour/doc/tracing.txt +++ b/harbour/doc/tracing.txt @@ -141,13 +141,23 @@ TRACING AND RUNTIME It is also possible to enable and disable tracing at run-time, and to query and set the trace level. From C code: -* To turn tracing completely off: +* To query the current tracing state, and optionally change the + current state to a given value (which should be in the range [0,1], + otherwise the current state remains unchanged): - hb_traceoff(); + hb_tracestate(state); -* To turn tracing back on: + Therefore, to just query the current state, you can safely call - hb_traceon(); + current_state = hb_tracestate(-1); + + To turn tracing completely off: + + hb_tracestate(0); + + To turn tracing back on: + + hb_tracestate(1); * To query the current tracing level, and optionally change the current level to a given value (which should be in the range [0,5], @@ -157,11 +167,10 @@ query and set the trace level. From C code: Therefore, to just query the current level, you can safely call - hb_tracelevel(-1); + current_level = hb_tracelevel(-1); There are wrapper functions callable from Clipper code: - TRACEOFF() - TRACEON() - TRACELEVEL(level) + current_state := HB_TRACESTATE( [new_state] ) + current_level := HB_TRACELEVEL( [new_level] ) diff --git a/harbour/include/hbtrace.h b/harbour/include/hbtrace.h index f0b98ac260..73f005c6b6 100644 --- a/harbour/include/hbtrace.h +++ b/harbour/include/hbtrace.h @@ -122,11 +122,9 @@ extern char * hb_tr_file_; extern int hb_tr_line_; extern int hb_tr_level_; -extern int hb_traceenabled( void ); -extern void hb_traceenable( int state ); -extern void hb_traceon( void ); -extern void hb_traceoff( void ); +extern int hb_tracestate( int new_state ); extern int hb_tracelevel( int new_level ); + extern int hb_tr_level( void ); extern void hb_tr_trace( char * fmt, ... ); diff --git a/harbour/source/common/hbtrace.c b/harbour/source/common/hbtrace.c index 3767b127dc..1c9d8a7ea2 100644 --- a/harbour/source/common/hbtrace.c +++ b/harbour/source/common/hbtrace.c @@ -67,24 +67,16 @@ static char * s_slevel[ HB_TR_LAST ] = "HB_TR_DEBUG" }; -int hb_traceenabled( void ) -{ - return s_enabled; -} -void hb_traceenable( int enabled ) +int hb_tracestate( int new_state ) { - s_enabled = enabled; -} + int old_state = s_enabled; -void hb_traceon( void ) -{ - s_enabled = 1; -} + if( new_state == 0 || + new_state == 1 ) + s_enabled = new_state; -void hb_traceoff( void ) -{ - s_enabled = 0; + return old_state; } int hb_tracelevel( int new_level ) diff --git a/harbour/source/rtl/trace.c b/harbour/source/rtl/trace.c index dbf1b94431..9f5d21542a 100644 --- a/harbour/source/rtl/trace.c +++ b/harbour/source/rtl/trace.c @@ -47,22 +47,9 @@ #include "extend.h" -HARBOUR HB_HB_TRACEENABLE( void ) +HARBOUR HB_HB_TRACESTATE( void ) { - hb_retl( hb_traceenabled() ); - - if( ISLOG( 1 ) ) - hb_traceenable( hb_parl( 1 ) ? 1 : 0 ); -} - -HARBOUR HB_HB_TRACEON( void ) -{ - hb_traceon(); -} - -HARBOUR HB_HB_TRACEOFF( void ) -{ - hb_traceoff(); + hb_retni( hb_tracestate( ISNUM( 1 ) ? hb_parni( 1 ) : -1 ) ); } HARBOUR HB_HB_TRACELEVEL( void )