However, the function can only handle one argument. How to handle more argmuments like print function?
GDScript doesn't not support variadic function arguments, so you have to use the following approach instead:
func debug_print(arg1 = "", arg2 = "", arg3 = "", arg4 = "", arg5 = "", arg6 = "", arg7 = "", arg8 = ""):
if OS.is_debug_build():
print(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
It's not very elegant, but it works :)
The above example supports up to 8 arguments, which is enough in nearly all sitautions you'd use a debug print for.