Make your life easier
|
Wednesday Grimm
Ex Libris
Join date: 9 Jan 2003
Posts: 934
|
07-05-2004 07:49
With this code
integer gnDebugLevel = 0; integer debug(integer nLevel, string szMessage) { if (nLevel <= gnDebugLevel) llSay(0, szMessage); }
Then put a call to this function at the beginning of every event and function, and every time your script does something interesting. This is the hard part, but it will pay off. Use a higher number for less interesting things, so you might have, for example:
default { state_entry() { debug(4, "default, state_entry"); [...] } touch_start(integer n) { debug(4, "default, touch_start"); if (llDetectedKey(0) == llGetOwner()) { debug(1, "switching to foobared state"); state foobared; } } }
Then, when something goes wrong down the line, all you have to do is set gnDebugLevel to a higher number, and you can see what's going on.
_____________________
Sarcasm meter: 0 |-----------------------*-| 10 Rating: Awww Jeeze!
|
Grim Lupis
Dark Wolf
Join date: 11 Jul 2003
Posts: 762
|
07-05-2004 08:09
In the spirit of log4j and log4net, might I make a recommendation?
LVL_ALL = 2147483647 LVL_DEBUG = 1000000 LVL_INFO = 10000 LVL_WARNING = -10000 LVL_ERROR = -100000 LVL_FATAL = -1000000 LVL_OFF = -2147483648
_____________________
Grim
"God only made a few perfect heads, the rest of them he put hair on." -- Unknown
|
Ace Cassidy
Resident Bohemian
Join date: 5 Apr 2004
Posts: 1,228
|
07-05-2004 09:21
I use something similar, but my debug function looks like this :
debug( integer nLevel, list debugList ) { if ( nLevel < gnDebugLevel ) llSay(0, llList2CSV(debugList)); }
This makes it easier to shoot out debug messages that contain the contents of variables and such. For example :
debug(1,["someVariable:",someVariable]);
|
Eggy Lippmann
Wiktator
Join date: 1 May 2003
Posts: 7,939
|
07-05-2004 10:54
Uh, I dont know what youve been coding lately... but this seems like a LITTLE bit of overkill... for something as simple as a silly scripting language. My code usually works right the first time. Yay me. When I have bugs its usually cause I was distracted... The last serious bug I had was months ago, because I slightly misunderstood the nature of dataserver calls, and outputting random crap wouldnt have helped me solve it. Thankfully, Catherine enlightened me  Love ya, cat 
|
Wednesday Grimm
Ex Libris
Join date: 9 Jan 2003
Posts: 934
|
07-05-2004 11:04
Well clearly you're much smarter than me Eggy. When debugging I often find that what I think is happening, and the order I think these things are happening in bears only a passing resemblance to what is actually going on. But I can find that out really fast by turning on my debugging messages. [Edit: Ohhhhh, I get it, Eggys crabby because he's from Portugal, be nice to him everyone  ]
_____________________
Sarcasm meter: 0 |-----------------------*-| 10 Rating: Awww Jeeze!
|
Rhysling Greenacre
Registered User
Join date: 15 Nov 2003
Posts: 132
|
07-05-2004 11:14
Debugging levels are a slight codesmell. It encourages one to make debug messages permanent. In my opinion debug statements ought to be stripped out after debugging.
|
His Grace
Emperor Of Second Life
Join date: 23 Apr 2004
Posts: 158
|
07-05-2004 11:35
From: someone Originally posted by Rhysling Greenacre Debugging levels are a slight codesmell. It encourages one to make debug messages permanent. In my opinion debug statements ought to be stripped out after debugging. i want macros... 
_____________________
I am not interested in happiness for all humanity, but happiness for each of us. - Boris Vian
|
Wednesday Grimm
Ex Libris
Join date: 9 Jan 2003
Posts: 934
|
07-05-2004 12:42
From: someone Originally posted by Rhysling Greenacre In my opinion debug statements ought to be stripped out after debugging. I agree, as soon as my script is perfect, and I am sure I will never need to edit it again, I take out all debugging statements.
_____________________
Sarcasm meter: 0 |-----------------------*-| 10 Rating: Awww Jeeze!
|
Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
|
07-05-2004 13:01
From: someone Originally posted by Wednesday Grimm I agree, as soon as my script is perfect, and I am sure I will never need to edit it again, I take out all debugging statements. That's the problem. I almost never know when I will never need to edit a script again. I wish there was some kind of "optional statement" type thing in LSL, kinda like asserts in Java. ==Chris
|
Wednesday Grimm
Ex Libris
Join date: 9 Jan 2003
Posts: 934
|
07-05-2004 13:23
Chris, I think you failed your Detect Irony roll.
_____________________
Sarcasm meter: 0 |-----------------------*-| 10 Rating: Awww Jeeze!
|