File Logger
With the latest update I have added a custom file logger, which you can create in your code and save the logging results to your custom folder.
Let's create a logger with name TestLogger
This modded script should be created in Module #3 - 3_Game, so you can access that across the whole app. Otherwise you can choose a different place. I just think it's convenient to have it accessible from most of the codebase of DayZ Server.
// Create a modded class for DayZGame script
modded class DayZGame
{
override void CRDTN_OnGameInit()
{
super.CRDTN_OnGameInit();
CRDTN_FileLogger.CreateInstance("TestLogger");
// instantiates the instance of FileLogger with key - TestLogger
//
}
};Congratulations, you have create your logger π The file will be saved in $profile/CRDTN/Logs/TestLogger.log
If you want a different location for your logs, you must rewrite the constant
CFG_CRDTN_LogsFolderNow you can access it from your code wherever you need by using the following code snippet.
CRDTN_FileLogger.GetInstance("TestLogger").Log("Some of your message");You can also cache the reference for more convenient work like below.
If you have followed the code above, you now can just call in the code
Be aware, that the example showcases usage of PluginBase which is part of module #4 so you can use the GetLogger() method only within module #4 and #5.
Last updated