On Wed, 16 Dec 2009, Pritpal Bedi wrote: Hi,
> > First build Harbour without HBQT. > > Then build HBQT in a separate pass with custom options. > > Rough instructions for that: > > --- > > set HB_WITH_QT= > > win-make > > cd contrib/hbqt > > set HB_WITH_QT=C:\qt\include > > set HB_USER_CFLAGS=-DTR_DEBUG_... > > set HB_USER_PRGFLAGS=-D__HB_DEBUG__ > > win-make > > cd ../.. > > --- > Can you expand <...> in > set HB_USER_CFLAGS=-DTR_DEBUG_... > I tried > set HB_USER_CFLAGS=-DTR_DEBUG > set HB_USER_CFLAGS=-DHB_TR_LEVEL_ALWAYS > but without success. > I am compiling hbqt/hbxbp/hbide only with these flags. > Harbour is compiled with default switches. > To be precise as: > HB_USER_CFLAGS=-D__HB_DEBUG__ -DHB_FM_STATISTICS -DHB_TR_LEVEL_ALWAYS > HB_USER_PRGFLAGS=-d__HB_WINDEBUG__ -d__HB_DEBUG__ With above you excluded at compile time all HB_TRACE messages with do not have HB_TR_ALWAYS priority. To clarify you do not need to recompile anything. It's enough if you understand how current code works. -DHB_TR_LEVEL_* is compile time macro used to strip from source code by PP all HB_TRACE() massages which have bigger priority value. By default it's set to: HB_TR_LEVEL_WARNING what means that: HB_TRACE(HB_TR_ALWAYS, ... ); /* 0 */ HB_TRACE(HB_TR_FATAL, ... ); /* 1 */ HB_TRACE(HB_TR_ERROR, ... ); /* 2 */ HB_TRACE(HB_TR_WARNING, ... ); /* 3 */ are compiled and included in final binaries and: HB_TRACE(HB_TR_INFO, ... ); /* 4 */ HB_TRACE(HB_TR_DEBUG, ... ); /* 5 */ are stripped by C preprocessor before compilation so no code is generated for them. When you use -DHB_TR_LEVEL_ALWAYS then it means that you exclude at compile time all HB_TRACE() messages except HB_TR_ALWAYS ones. At .prg level you can use hb_traceString() function to generate HB_TR_ALWAYS messages. below I'm attaching small test code which shows different HB_TRACE messages generated from C and .prg code. HB_TRACE() messages which were compiled are filtered also at runtime. By default the filter is set to HB_TR_WARNING what means that HB_TR_ALWAYS, HB_TR_FATAL, HB_TR_ERROR and HB_TR_WARNING are shown but HB_TR_INFO and HB_TR_DEBUG are ignored. This filter can be changed by HB_TR_LEVEL=<level> envvar set before application starts, i.e. to show all compiled messages: set HB_TR_LEVEL=DEBUG or to show only HB_TR_FATAL and HB_TR_ALWAYS: set HB_TR_LEVEL=FATAL By default HB_TRACE() messages are redirected to STDERR and if you want then you can redirect them to file using 2> shell operator (of course if it supports it), i.e.: myprog.exe 2> mytrace.log Alternatively they can be also redirected to file by setting HB_TR_OUTPUT envvar, i.e.: set HB_TR_OUTPUT=mylog.txt Additionally in Windows builds you can redirect copy of all HB_TRACE() messages to OutputDebugString() function. It's enough to set HB_TR_WINOUT envvar to some not empty value, i.e.: set HB_TR_WINOUT=1 The messages are written to STDERR or user file using stdio functions which can buffer data. It speedups the execution time but in some cases you may want to force writing each message immediately, i.e. to trap messages which can be lost due to GPF before buffer flushing. You can enable such flushing by setting HB_TR_FLUSH envvar to any non empty value, i.e.: set HB_TR_FLUSH=1 This switch has no effect on HB_TR_WINOUT for which Harbour do not make any buffering. I hope that now it's more clear for you and other Harbour developers how HB_TRACE system works. For sure it's much more flexible then direct calling some *_trace*() function. I hope you will find it very useful. I.e. in your .c code you can use HB_TR_INFO messages which are stripped by default at compile time, i.e.: HB_TRACE(HB_TR_INFO, ("[...@%s]", "this is tracelog test", "INFO")); and do not cause any runtime overhead in default builds. But if you will want to enable them, then it's enough to recompile your code with HB_USER_CFLAGS=-DHB_TR_LEVEL_INFO and then before you start final application: set HB_TR_LEVEL=INFO set HB_TR_OUTPUT=mylog.txt Unfortunately we do not have such flexible interface at .prg level and here you can use only hb_traceString() function to generate HB_TR_ALWAYS messages. In general .prg level support for HB_TRACE() messages should be extended and in few places fixed. Now we have three functions: hb_traceState( [<nNewState:0|1>] ) -> <nPrevState> hb_traceLevel( [<nNewLevel>] ) -> <nLastMsgLevel> hb_traceString( <xMsgItems, ....> ) -> NIL hb_traceState() enable and disable HB_TRACE system. By default it's enabled. Now hb_traceLevel() does not make anything usable. I can only guess it's mistake of someone who wanted to give .prg level interface for setting default runtime HB_TRACE message filter so it could be used instead of setting HB_TR_LEVEL envvar. It should be fixed to work in such way or removed to nor confuse users. hb_traceString() convert passed parameters to string using the same conversion method as ?/?? commands ([Q]QOUT()) so at least its name is confusing. It shows all messages using only HB_TR_ALWAYS level, does not set valid PRG function name and line in generate messages and does not show context of complex variables like arrays or hashes (just like ?/??) what can be usable in some cases. I think that it should be replaced by two new functions: hb_traceLogLevel( <nNewLevel> ) -> <nPrevLevel> hb_traceLog( <xMsgItems,...> ) // generate message at hb_traceLogLevel() and we should add also: hb_traceLogAt( <nLevel>, <xMsgItems,...> ) which will allow to create PP rules giving the same functionality as we have now at C level. HTH, best regards, Przemek proc main() ? "HB_TRACESTATE:", HB_TRACESTATE() ? "HB_TRACELEVEL:", HB_TRACELEVEL() ? HB_TRACESTRING( "Test for HB_TRACESTRING() (.prg code)", hb_dateTime() ) ? TR_TEST() return #pragma begindump #include "hbapi.h" HB_FUNC( TR_TEST ) { HB_TRACE(HB_TR_ALWAYS, ("[...@%s]", "this is tracelog test", "ALWAYS") ); HB_TRACE(HB_TR_FATAL, ("[...@%s]", "this is tracelog test", "FATAL") ); HB_TRACE(HB_TR_ERROR, ("[...@%s]", "this is tracelog test", "ERROR") ); HB_TRACE(HB_TR_WARNING, ("[...@%s]", "this is tracelog test", "WARNING") ); /* default trace level is HB_TR_WARNING so this lines * will be stripped if compiled without valied HB_TR_* macro */ HB_TRACE(HB_TR_INFO, ("[...@%s]", "this is tracelog test", "INFO") ); HB_TRACE(HB_TR_DEBUG, ("[...@%s]", "this is tracelog test", "DEBUG") ); } #pragma enddump _______________________________________________ Harbour mailing list (attachment size limit: 40KB) Harbour@harbour-project.org http://lists.harbour-project.org/mailman/listinfo/harbour