Logging - ParkitectNexus/ParkitectNexusClient GitHub Wiki


UnityEngine.Debug.Log

The Unity way of logging is via UnityEngine.Debug.Log(...) and its variants. The log file is Parkitect\Parkitect_Data\output_log.txt. Uncatched exceptions are logged to that file too (with their StackTrace). The log file's created new every time Parkitect starts. New messages are added at the end of the file when they are logged. That means you must reload the file in your text editor to see new logs. Some text editors can auto-refresh a file when it changed (e.g. Notepad++ with a "Document monitor" plugin).

Besides opening the log file in a text editor, a debug console with the log messages and exceptions can be brought up in Parkitect by hitting Ctrl+Alt+D. However that window only displays messages that are logged while it's open.
Debug Console

ModTools.Debug

ModTools.Debug provides a wrapper around UnityEnginge.Debug.Log but can also put your log messages into the Parkitect notification bar.
Log message in Notification bar
You can switch the output by setting consoleOnly: if false it displays messages in the notification bar, else (false) it uses UnityEngine.Debug.Log and therefore outputs the debug messages to Parkitect\Parkitect_Data\output_log.txt.

The available logging command are:

  • LogMT(string text): Logs the passed text. Prepends Debug.textPrefix and the current time (if Debug.showTime is enabled).
    • this function is the base for all other LogMT methods.
  • LogMT(List<string> texts): Logs each passed string individually.
  • LogMT(string[] names, string[] values): For key-value pairs.
    • Each pair is logged individually.
    • names and values must have the same length.
  • LogMT(string[] names, long[] values, uint mode = 0): For key-value pairs.
    • mode=0: same as above, values are just converted into strings
    • mode=1: assumes values are unix timestamps and converts them into date time
    • mode=2: assumes values are durations in ms and converts them into time span
    • Last two are useful for measuring time like with System.Diagnostics.StopWatch
⚠️ **GitHub.com Fallback** ⚠️