[Lazarus] Maybe using CodeTools to modify source code

Martin lazarus at mfriebe.de
Wed May 8 14:45:05 CEST 2013


On 08/05/2013 13:15, Graeme Geldenhuys wrote:
> On 2013-05-08 12:59, Martin wrote:
>> Do something like lazlogger does.
> Thanks for the suggestion, I'll take a closer look at lazlogger. I do
> prefer not to leave debug code in all my units though. Otherwise I could
> simply continue using my code templates ('sme' and 'smx') that inserts
> code like
>
>   {$IFDEF DEBUG}SendMethodEnter('SomeClass.SomeMethod');{$ENDIF DEBUG}
>
>
> Also, sometimes I would like to only trace a select few methods in a
> class or unit. With the checkbox treeview idea that should make it very
> easy to do, and revert those changes when I am done.
>

Lazlogger can do selected.

It has 3 levels

LazLoggerDummy: empty methods (the ones wit open array, may generate 
some code, the rest should not)

LazLoggerBase: always generates code, but installs an inactive logger 
object (use in packages, then the project can activate it)

LazLogger: the full deal (use in project)


register an option:

var
   DBG_LOCATION_INFO: PLazLoggerLogGroup;
initialization
   DBG_LOCATION_INFO := 
DebugLogger.FindOrRegisterLogGroup('DBG_LOCATION_INFO' {$IFDEF 
DBG_LOCATION_INFO} , True {$ENDIF} );


     debugln(DBG_LOCATION_INFO, 'Text');

will only log if called with commandline (or set in project)
--debug-enable=DBG_LOCATION_INFO





More information about the Lazarus mailing list