-
Notifications
You must be signed in to change notification settings - Fork 52
Logger
QModManager has a utility built into it to help mods log relevant errors or even just info that you wish to track in the games own log file and optionally on screen in-game.
The log file can be found in the base game folder with the name qmodmanager_log-Subnautica.txt
or qmodmanager_log-SubnauticaZero.txt
, depending on the game.
You can access this utility through QModManager.Utility.Logger
and there are 3 things you can access.
First is an Enum
for what Level your logging will be showing when your message:
public enum Level
{
Debug,
Info,
Warn,
Error,
Fatal
}
Second is a bool
called DebugLogsEnabled which you can use to check if the player has enabled the debug logs of QMM in the options menu.
The third is the actual Log Method which has the following parameters:
Level: This is from the Enum above. Mandatory.
string: This is your message you want logged. Optional: (Default = null)
Exception: You can pass through an exception to be logged. Optional: (Default = null)
bool: Used if you want to display the message in-game on screen. Optional: (Default = false)
public static void Log(Level logLevel, string msg = null, Exception ex = null, bool showOnScreen = false)
While Message and Exception are both optional if both are left as null then the logger will return without doing anything.
Simple example
using QModManager.Utility;
//....
Logger.Log(Logger.Level.Info, "My mod did something");
Logger.Log(Logger.Level.Debug, "Show my mod did something on screen", true);
If there is something missing or ambiguous, please create an issue or contact us on the Subnautica Modding Discord using our tags:
- PrimeSonic:
@PrimeSonic#0667
- Metious:
@Metious#3682