Skip to main content

Logs

Construct follows the principle of logs minimization, meaning it only logs errors and warnings with the purpose of letting the developers know something is wrong or unexpected and let them fix the issue. If the fix works, the logged errors and warnings should disappear. Construct does not log on the information level by default.

Logging can be resource intensive and it's usually good practice to not leave logs inside library code. But sometimes it could help pinpointing possible critical execution paths or bugs, even when going through libraries.

This is why info logs can be toggled on through the Menu bar, by clicking Construct > Toggle Logs ON/OFF. The same behaviour can be applied outside Construct by using

Log.Info(object message);
Log.Info(object message, UnityEngine.Object context);
Log.Format(string format, params object[] parameters);
Log.Format(UnityEngine.Object context, string format, params object[] parameters);
Log.Format(LogType logType, LogOption logOptions, Object context, string format, params object[] args);

instead of the Unity's Debug.Log version. The same functions are available for both Warnings (Log.Warning) and Errors (Log.Error), as well as for Exceptions (Log.Exception.) It is good practice to not hide them though, not even in release builds.

important

String literals passed to the log method is allocated even if Logs are turned off. In order to avoid that, explicitly wrap a normal Debug.Log call in a #if CONSTRUCT_LOGS_ACTIVE block.