How to use/setup DebugLog?

I am confused about every piece of DebugLog.

I posted yesterday induced-garbage-collection and wrote I would look for information on DebugLog.
I can find nothing substantial. Only pieces of code that apparently trap information.
I found a couple of mentions in the blog of logging.
I know it’s been around for a while but I cannot find any explanation of it.
Things I am missing are:

How different is it from the debugger’s pane?
Is it always available?
How much detail do I need to go in to trap a Boolean?
What does the output look like?
What if want to trap an array?
Are there other similar features?
How do you know CurrentMethodName from System is correct one to use?
What can I trap from a class? Every piece of info?
What can I not get?

I have no idea what else I can get.

Simply put, you include in your code stuff like this:

System.DebugLog "Creating Dictionary"
dim d as new Dictionary

if d is nil then
  System.DebugLog "... but it's nil. Wut?!?"
end if

System.DebugLog "Assigning values to Dictionary"

When your code runs, it logs those messages so you can examine them in realtime. Because you define the messages and where they appear, you can use this technique to make sure your code is doing what you think it’s doing and that variables are what you think they are. (Or anything else you’d find helpful.)

The easiest way to get to that log is in the IDE at the bottom of the code editor. There are three tabs there, one for the search pane, the next for compiler messages, and the third for the log. While your app is running through the IDE, open that third pane and watch the messages fly.

In your case, if there is a race condition that isn’t showing up when you drop into the debugger, you should be able to craft messages to expose it.

I have mentioned this before… But a while back I tried to use System.DebugLog and found that either messages never showed up, lagged way behind the event, or in some cases appeared out of order. So I gave up… and created my own solution.
While its not elegant, I found that it never lagged, never was out of order, and the performance hit to the running app was acceptable during testing/debugging (as in neglible)

I add this method to my code, and call it instead of “System.DebugLog”

Public Sub debug(msg As String,force as Boolean=false)
  //return //  <---- just uncomment this line to deactivate the Debug logger across the entire app
  Dim f As FolderItem
  Dim t As TextOutputStream
  If msg="!!!" Then
    If f.exists Then f.delete
    Exit Sub
  End If
  #If DebugBuild Then
  If force Then 
    If Not f.exists Then
    End If
    t.write Str(Ticks)+":"+msg+EndOfLine
  End If
End Sub

then to use Kems example

DEBUG  "Creating Dictionary"
dim d as new Dictionary

if d is nil then
  DEBUG "... but it's nil. Wut?!?"
end if

DEBUG  "Assigning values to Dictionary"

Thanks to both.
I will try them but the nagging question of “Race Conditions” is there.
I don’t use threads so I don’t have the option waiting until it’s complete.
I also have no idea how to debug for that.

Unfortunately, that’s a question specific to your code and the type of problem you’re having.

BTW, every method creates a constant, CurrentMethodName, that you can use for logging. I like to do something like this:

System.DebugLog CurrentMethodName + ": My message"

Do you understand how to display the DebugLog messages ?

To whom are you asking that question? If to me, then yes, yes I do, but if you read my post, you will see my specific reasons for not using this method, it is very very slow, and it is not in synch with the events as they happen

Thanks Dave

My guess is that Emile’s question is to Arthur.

I actually like Dave’s comment. After watching his comments, I recognize his pointing and reminding me of a different solution.

But no answer after 7 hours…

And I read Dave answer.

I basically understand how to get a debugLog. I do wish someone did a blog or something on quirky debugging techniques like this.

I don’t see what the difficulty is. I have a global (debugfl) which I can clear/set with a button. So if I want to log something, anywhere in the app, I can do:

if (app.debugfl=true) then // Write to log here end if

Since my app has a textarea in which it reports things to the user, I can just use that to report debug output. Here is an actual example:

if (app.debugfl=true) then writeLogging ("Initialise at 2 - filetype: " + mboxtype.ToText + " dbpath: '" + dbpath + "'")

Normally when the app runs, debugfl is false, of course. I have about 100 statements like this for different reasons scattered throughout the app. When developing this I didn’t know about system.debuglog, but I still prefer not to use that as the app itself can display the debugging output.

Thanks. It is another viewpoint