Added timestamps

One of my favorite things in this course is the debug console on the phone. I have made a small addition to it to make it more helpful. I put the following function in the MyUtility singleton:

func timestamp():
var time = Time.get_time_dict_from_system(false)
var current_time = “%02d:%02d:%02d” %[time.hour, time.minute, time.second]
return current_time

This allows me to call MyUtility.timestamp() and get back a formatted string (the ‘false’ flag in the function call is to make it local time rather than utc). This was pulled from StackOverflow when I went poking around how to access system time in gdscript.

In this lecture I adjusted the connection message to:

MyUtility.add_log_message(MyUtility.timestamp() + “: Connected to Google Payments”)

I did similar adjustments for the error and disconnect messages.

This isn’t super important, but I felt it was worth mentioning, especially for use in larger projects that might want more robust logging down the line.

Privacy & Terms