Last active
May 11, 2023 16:34
-
-
Save caligari87/e77f102633919c55f9fa38076187c734 to your computer and use it in GitHub Desktop.
A simple implementation of a debug logging system, which can filter messages based on the a bitfield cvar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server int MyMod_DebugFilter = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Bitfield values | |
enum MyMod_DebugFilters { | |
DBG_Filter1 = 1, | |
DBG_Filter2 = 2, | |
DBG_Filter3 = 4, | |
DBG_Filter4 = 8, | |
DBG_Filter5 = 16, | |
DBG_Filter6 = 32, | |
DBG_Filter7 = 64, | |
DBG_Filter8 = 128, | |
}; | |
class MyModUtilities { | |
static play void LogDebug(int dbgfilter, string message) { | |
if (MyMod_DebugFilter & dbgfilter) { | |
console.printf(message); | |
} | |
} | |
} | |
class TestActor : Actor { | |
override void PostBeginPlay() { | |
super.PostBeginPlay(); | |
MyModUtilities.LogDebug(DBG_Filter1, string.format("My classname is "..self.GetClassName())); | |
MyModUtilities.LogDebug(DBG_Filter2, string.format("The current map tick is"..level.maptime)); | |
MyModUtilities.LogDebug(DBG_Filter3, string.format("The host player's health is "..players[0].mo.health)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment