package Printing import NoWurst import Player import Annotations @configurable public var DEBUG_LEVEL = Loglevel.INFO @configurable public var DEBUG_MSG_DURATION = 45. public enum Loglevel TRACE DEBUG INFO WARNING ERROR @configurable public function Loglevel.getTag() returns string switch this case TRACE return "|cffADADADtrace|r" case DEBUG return "|cff2685DCdebug|r" case INFO return "|cffFFCC00info|r" case WARNING return "|cffF47E3Ewarning|r" case ERROR return "|cffFB2700error|r" // Wrapper for nice log syntax public class Log /** Prints a trace logmessage */ static function trace(string msg) printLog(localPlayer, Loglevel.TRACE, msg) /** Prints a debug logmessage */ static function debug(string msg) printLog(localPlayer, Loglevel.DEBUG, msg) /** Prints a info logmessage*/ static function info(string msg) printLog(localPlayer, Loglevel.INFO, msg) /** Prints a warning logmessage */ static function warn(string msg) printLog(localPlayer, Loglevel.WARNING, msg) /** Prints a warning logmessage */ static function error(string msg) printLog(localPlayer, Loglevel.ERROR, msg) static function setLevel(Loglevel lvl) DEBUG_LEVEL = lvl /** Prints a simple message. */ @configurable public function print(string msg) DisplayTimedTextToPlayer(localPlayer, 0., 0., DEBUG_MSG_DURATION, msg) /** Prints a simple message. */ @configurable public function print(int msg) // Using JASS' original converter function // in order not to mess up the structure of wurst's basic code print(I2S(msg)) /** Prints a simple message. */ @configurable public function print(real msg) print(R2S(msg)) /** Prints a simple message. */ @configurable public function print(bool msg) var msgString = "False" if msg msgString = "True" print(msgString) /** Prints a special motification-message */ @configurable public function printLog(Loglevel loglvl, string msg) printLog(localPlayer, loglvl, msg) @configurable public function printLog(player showTo, Loglevel loglvl, string msg) if (DEBUG_LEVEL castTo int) <= (loglvl castTo int) let compositeMsg = loglvl.getTag() + " - " + msg DisplayTimedTextToPlayer(showTo, 0., 0., DEBUG_MSG_DURATION, compositeMsg) /** Prints a simple message that is shown for the given duration */ @configurable public function printTimed(string msg, real duration) DisplayTimedTextToPlayer(localPlayer, 0., 0., duration, msg) /** Prints a simple message that is shown for the given duration */ public function print(string msg, real duration) printTimed(msg, duration) /** Prints a simple message that is shown to the player for the given duration */ @configurable public function printTimedToPlayer(string msg, real duration, player p) DisplayTimedTextToPlayer(p, 0., 0., duration, msg) /** Prints a timed message that is shown to the player for the given duration */ public function player.print(string msg, real duration) printTimedToPlayer(msg, duration, this) /** Prints a simple message that is shown to the player */ public function player.print(string msg) printTimedToPlayer(msg, DEBUG_MSG_DURATION, this) /** Prints a simple message after clearing all messages that is shown to the player for the given duration */ public function printTimedToPlayerClear(string msg, real duration, player p) if localPlayer == p ClearTextMessages() DisplayTimedTextToPlayer(p, 0., 0., duration, msg)