I started to add a new feature in a some month old project and needed to get some variable contents (the variables name are meaningful, but not enough…).
So I used
System.DebugLog. Then, I wanted to Copy / Paste these information for later reminder.
Not possible with Xojo 2015r1. Before using drastic measures (save it into a text file for example), I checked what happens with the current version (Xojo 2021r2):
Fantastic: Copy / Paste works fine !
Thank you Xojo for this addition.
Note to self: it may be a good idea to generate a DebugLog file, so I will always have handly the running flow in case I need it (for debug or a repport of how things works while I implement a new feature.
A new Method whose syntax can be
Debug_Log("My debug string")…
What is your feeling ?
For stored/saved/permanent logging, use System.Log instead?
Thank you Sasha.
Care to explain how it is better ?
I implemented the Save to file text debug stuff. It was nice and allow me to write code faster (less run / debug | write code / run), à la DB when you have a software that allow you to read what you wrote in the db file.
you could use https://documentation.xojo.com/topics/os_information/conditional_compilation.html
for each feature or part that you want to debug log.
its also good to enable the log by menu or key phrase to shrink the output.
also useful for logging
Better? “Better” always depends (on various things).
I just thought “why write a debug/error/crash/… log-file mechanism” while the underlying OS’s already offer standardized mechanisms for collecting/storing/sharing/… such information? On Windows it’s the Event Log and on macOS/Linux/Raspi it’s the System Log.
The feature takes a long string and split it in some “atoms”.
I needed to know the long string + atom name and atom contents. Placing it into a Text file fits my needs.
If my license was current, I only took what System.DebugLog returns, but this is not the case.
This adds one line in App.Open, a dedicated Module and some lines in the new feature. Not a big deal.
BTW: better includes… something I was not thinking off ;-
I do not included
#If DebugBuild Then for example.
The only thing I have to add with using the system log is that App Sandboxed apps cannot retrieve the contents of the log, if you want to provide the ability for a customer to mail you the log.
Thank you Sam. This is a log for me, my use only. It’s a way to try to avoid errors at code writing time and speed up the debug a bit.
Of course, I could have gone the Console or Terminal way, but it was faster and easier to do it that way.