DebugLog

BlitzMax Forums/BlitzMax Programming/DebugLog

therevills(Posted 2009) [#1]
Hi All,

Just wondering if I should remove Debuglog statements from release code?

Does it add any overhead to the compiled release code?

Cheers


GW(Posted 2009) [#2]
It get skipped when you compile in release mode. Same with Asserts.


_Skully(Posted 2010) [#3]
I understand the assert command but a single like check like that is only so useful... is there no equivalent to:

if debug
    ' don't compile this code if its not in debug mode?
	If StartValue<NextValue
		Assert Value<StartValue Or Value>NextValue ELSE "Value Breach"
	Else
		Assert Value>StartValue Or Value<NextValue ELSE "Value Breach"					
	End If
end if



Brucey(Posted 2010) [#4]
You can do this if you don't want any code compiled :
?debug
    ' don't compile this code if its not in debug mode?
	If StartValue<NextValue
		Assert Value<StartValue Or Value>NextValue ELSE "Value Breach"
	Else
		Assert Value>StartValue Or Value<NextValue ELSE "Value Breach"					
	End If
?



Blueapples(Posted 2010) [#5]
Check out the Conditional Compiling section of the manual under Help/Language:

Conditional compiling works a bit like an If statement, but takes the form:

?Identifier
The ? must appear at the start of a new line, and Identifier should be one of the following:

Name		Meaning
Debug		True if program is being compiled in debug mode.
Threaded	True if program is being compiled in threaded mode.
Win32		True if program is being compiled for the Windows operating system.
MacOS		True if program is being compiled for the MacOS operating system.
Linux		True if program is being compiled for the Linux operating system.
X86		True if program is being compiled for the Intel CPU.
PPC		True if program is being compiled for the PowerPC CPU.
MacOSX86	True if program is being compiled for an Intel Mac.
MacOSPPC	True if program is being compiled for a PowerPC Mac.
BigEndian	True if program is being compiled for a big endian CPU.
LittleEndian	True if program is being compiled for a little endian CPU.


Identifier may also be preceded by Not to invert the result.



Blueapples(Posted 2010) [#6]
Doh Brucey you beat me to the post


GfK(Posted 2010) [#7]
I never leave debug stuff in there, whether you're allowed to or not.

BLIde has a handy "find in files" option. Type DebugLog into the search box, click each result, then delete the line. Simples.


Brucey(Posted 2010) [#8]
I never leave debug stuff in there, whether you're allowed to or not

I have to say, I'm the same.

Perhaps if my apps were big enough to require some "proper" logging, I would probably use that instead.

Hasn't anyone created a "Log4Max" module? :-p
(No, really, I was being serious... we use Log4J and Log4CPP at work)


Czar Flavius(Posted 2010) [#9]
I've never found myself using Debug logs. I just put a DebugStop before a point of interest and peek directly, or just Print stuff out.


Muttley(Posted 2010) [#10]
Well, I use my own logger module as well as DebugStop and printing stuff out. It entirely depends on the sort of issue you're looking into.

My module if anyone wants to try it: http://muttmod.googlecode.com/files/logger.mod-1.1.0.rar


Otus(Posted 2010) [#11]
To answer the OP,

DebugLog and DebugStop are functions that do nothing in release mode. They still get called for a small overhead that might be significant in extreme circumstances. Assert on the other hand is a keyword that does not result in any code in release mode.