![Equinox-EquinoxsDebuggingTools icon](https://gcdn.thunderstore.io/live/repository/icons/Equinox-EquinoxsDebuggingTools-1.0.2.png.128x128_q95.png)
EquinoxsDebuggingTools
A library that solves logging issues and provides debugging tools.
Last updated | 2 months ago |
Total downloads | 336 |
Total rating | 0 |
Categories | Libraries |
Dependency string | Equinox-EquinoxsDebuggingTools-1.0.2 |
Dependants | 2 other packages depend on this package |
README
Equinox's Debugging 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 CreativeFlight mod as an example:
In my mod is the line, EDT.Log("Status", "Flying Started");
. The first time that EDT see's a category ("Status"), it creates a config entry like this:
[Mods.CreativeFlight]
## Whether debug messages should be logged for CreativeFlight - Status
# Setting type: Boolean
# Default value: false
Debug Status = false
Since this value defaults to false, calls to Log()
that use the category 'Status' 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 :EquinoxsDebuggingTools] [CreativeFlight|Status|CreativeFlight.Jetpack.StopFlight]: Stopped Flying
The message is given a prefix with the format:
[Calling DLL Name|Category|Calling Function 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 true
. Set this entry to true
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 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.PacedLog("Category", "My Message");
Then for your last one in the function, specify the delay before the next group are sent:
EDT.PacedLog("Category", "Last Message In Function", 0.25f);
SetPacedLogDelay()
public static void SetPacedLogDelay(
float delaySeconds
)
This function sets the delay that must occur before any more PacedLog() messages are logged. Use this at the end of your Update() function if the last PacedLog() call is in a loop.
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 true
if obj
is not null. Think of this function as a test, see example use for a better explanation.
Note: If obj
is null, a warning level messaeg will always be logged, regardless of shouldLog
.
Example use:
if(NullCheck(UIManager.instance, "UI Manager"){
if(NullCheck(UIManager.instance.techTreeMenu, "Tech Tree Menu")){
TechTreeNode node = UIManager.instance.techTreeMenu.GridUI.GetNodeByUnlock(...);
}
}
This could also be written using guard clauses:
if(!NullCheck(UIManager.instance, "UI Manager")) return;
if(!NullCheck(UIManager.instance.techTreeMenu, "Tech Tree Menu")) return;
TechTreeNode node = UIManager.instance.techTreeMenu.GridUI.GetNodeByUnlock(...);
Read those first two lines as 'If the null check fails, return'
DebugObject()
public static void DebugObject(
object obj,
string name
)
This function loops through each member of the obj
argument and logs its type, name and value.
Example use:
class Item{
int id;
string name;
double secondsToCraft;
}
Item ironIngot = new Item(){ id = 0, name = "Iron Ingot", secondsToCraft = 0.5 };
EDT.DebugObject(item, "ironIngot");
Output:
[Info :EquinoxsDebuggingTools] Debugging Item 'ironIngot':
[Info :EquinoxsDebuggingTools] int id = 0
[Info :EquinoxsDebuggingTools] string name = "Iron Ingot"
[Info :EquinoxsDebuggingTools] double secondsToCraft = 0.5
Config Options
Name | Type | Description | Default Value |
---|---|---|---|
Force Debug Logging Off | Toggle | When enabled, no debug messages from mods using EDT will be logged. | True |
Developer Mode | Toggle | When enabled, new config entries will default to true | False |
Installation
If you are using Techtonica Mod Loader, you can ignore these steps.
Note, this mod requires use of the BepInEx Update function. If you have not already done so for another mod, follow these instructions:
- Find your game install folder.
- Navigate to BepInEx\config.
- Open BepInEx.cfg.
- Find the setting "HideGameManagerObject".
- Set it to "true".
- Save & close.
Techtonica Mod Loader Installation
You can download the Techtonica Mod Loader from here and use that to install this mod.
Manual Install Instructions
Note: If you are playing on Gamepass, your game version is likely behind the steam version. Please check the version compatibility chart below.
Your game folder is likely in one of these places:
• Steam: (A-Z):/steam/steamapps/common/Techtonica
• Gamepass: (A-Z):/XboxGames/Techtonica/Content
• Gamepass: Could also be in C:/Program Data/WindowsApps
- Download BepInEx v5.4.21 from here
- Follow the installation instructions here
- Download and install any dependencies.
- Extract the contents of the .zip file for this mod.
- Drag the "BepInEx" folder into your game folder.
- Change config options.
Changelog
V1.0.2
- Changed: PacedLog()
- Changed PacedLog() so that the delay given in the argument must occur after a message is logged rather than before. This means you can send multiple PacedLog() messages per update, but still prevent performance issues from too much logging.
- Added: SetPacedLogDelay()
- Added a function that can be used to trigger a delay in PacedLog() messages without sending a log. Put at the end of your Update() function if your last PacedLog() call is in a loop.
V1.0.1
- Fixed: PacedLog()
- Fixed a bug that caused PacedLog() to not work correctly
V1.0.0
Initial Release
Credits
Disclaimer
Note: NEW Games must be loaded, saved, and reloaded for mods to take effect. Existing saves will auto-apply mods. Please be sure to backup your saves before using mods: AppData\LocalLow\Fire Hose Games\Techtonica USE AT YOUR OWN RISK! Techtonica Devs do not provide support for Mods, and cannot recover saves damaged by mod usage.
Some assets may come from Techtonica or from the website created and owned by Fire Hose Games, who hold the copyright of Techtonica. All trademarks and registered trademarks present in any images are proprietary to Fire Hose Games.