EquinoxsDebugTools

版本 v1.0.1·更新於 2025-05-07

A library that solves logging issues and provides debugging tools

截圖 共 1 張

模組介紹 作者原文

Equinox's Debug Tools

Description

This library's primary purpose is to solve the issue of having debug logging in release versions of our mods. Doing this with simple Log.Debug() calls is impractical, as logs end up full of spam, so we delete all our debug logging before release, only to add it back in when someone has an issue that we can't replicate. We could have our logging controlled by bools in the source, but this is a lot of effort and it's easy to forget to set them to false, so this library automates that process.

By using this library, all your debug logging will automatically be disabled when a player installs your mod. Then when they run into issues, you can tell them which config option to enable in order to get the debug info you need.

This library also provides several other functions that are helpful for debugging.

Usage

Log()

public static void Log(

string category,

string message

)

This function logs the message given in the argument if the player has enabled debug messages for the given category. Using my MapHotkey mod as an example:

In my mod is the line,.Log("Zoom Updates", "Set zoom level to 6400");. The first time that EDT see's a category ("Zoom Updates"), it creates a config entry like this:

[Mods.MapHotkey]

Whether debug messages should be logged for MapHotkey - Zoom Updates

Setting type: Boolean

Default value: false

Debug Zoom Updates = false

Since this value defaults to false, calls to () that use the category 'Zoom Updates' will be ignored. If a player has an issue, I can tell them to enable this particular config entry to generate debug information without needing to send them a new version with new or enabled logging. Once the player has enabled this option, I will see this in their log:

[Debug:EquinoxsDebugTools] [Zoom Updtes|MapHotkey.MapHotkeyPlugin.Update()]: Set zoom level to 6400

The message is given a prefix with the format:

[Category|Calling Function Path/Name]:

This is to help you see where the message came from in case you have similar debug statements in different funtions.

EDT has a config entry called 'Developer Mode'. When this is set to true, new config entries generated by EDT will default to. Set this entry to to avoid having to manually enable config entries while working on mods.

PacedLog()

public static void PacedLog(

string category,

string message,

float delaySeconds = 0f

)

This function works in the same way as above, but it also prevents any other PacedLog() messages from the same function being logged until the delay has ended. This is useful to use in Update() functions as logging every frame can cause performance issues that make developement very difficult, as well as bury important messages in spam.

If you want to log multiple things in an Update() function, for all but the last write:

EDT.Logging.PacedLog("Category", "My Message");

Then for your last one in the function, specify the delay before the next group are sent:

EDT.Logging.PacedLog("Category", "Last Message In Function", 1f);

SetPacedLogDelay()

public static void SetPacedLogDelay(

float delaySeconds

)

This function sets the delay that must occur before any more PacedLog() messages from the same function are logged. Use this at the end of your function if the last PacedLog() call is in a loop.

Example:

void Update(){

for (int i = 0; i ) {

EDT.Logging.PacedLog("Category", $"My Message Num {i}");

}

EDT.Logging.SetPacedLogDelay(1f)

}

NullCheck()

public static bool NullCheck(

object obj,

string name,

bool shouldLog = false

)

This function can be used to check if the provided object is null and log the result. It's a little cleaner to use this than multiple manual null checks if there's more than one to do in a function.

Returns if is not null. Think of this function as a test, see example use for a better explanation.

Note: If is null, a warning level messaeg will always be logged, regardless of.

Note: Code examples from this point on are written for Techtonica's code

安裝與使用 安裝:按包內說明操作

  1. 解壓本站下載的壓縮包,先讀包內的 readme / 說明檔案。
  2. 多數模組依賴遊戲的模組載入器:常見做法是用社群模組管理器(如 r2modman)選中本遊戲安裝,由管理器自動處理載入器與依賴。
  3. 手動安裝時,把模組檔案放進遊戲目錄下對應的 Mod / plugins 資料夾。
  4. 啟動遊戲確認載入成功;帶「前置依賴」的模組需要把依賴一併安裝。

不同模組的安裝位置差異較大,包內說明是最可靠的依據。

檔案與校驗

檔案名稱
EquinoxsDebugTools-1.0.1.zip
檔案大小
95.2 KiB