Am Mon, 16 May 2011 13:01:39 +0300 schrieb ik <ido...@gmail.com>: > procedure toLog(const S : String); <------ > {$IFDEF DEBUG} | > .... | > {$ENDIF} | > end; | | What do you think, is my debug thing? It is this. What you write, but in an unit and an included file, so I never have to think about again. But approved to vanish completely.
> > It's not a hack but a choice to insert things to log. > I can also create something like this: > > procedure toLog(debug_level : TDebugLevel; const S : String); > {$IFDEF DEBUG} > if debug_level <= current_debug_level then > writeln(debug_to_str(debug_level), ' [', DateTimeToStr(now) ,'] > ', s); {$ENDIF} > end; OK, this is a starting point, I think many programmers start with something like this. After they have done writeln and commenting out a bit. What my debug system does, is exactly this, what your example code does. A little more. -You can not use the compile time information %LINE% %FILE% ... in your procedure because they would expand to the information from your procedure. -You are forced this way to use run-time information -Where go the units in the uses clause. Some writing of ifdefs? OK. -Is the code really vanishing if you switch debug off? In this simple example, maybe, if inlined. -How do you retrieve the function name, line number, file name and how do you give it to the procedure? Really Much Writing?? Not done therefor. A macro has the possibility to expand where used, and this way you can circumvent the Really Much Writing. Thats all. Jörg _______________________________________________ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel