- Joined
- Apr 24, 2012
- Messages
- 5,113
Because i don't have WE/JNGP in this PC and my other PC was so far to this location,can i ask somebody to test this WIP?
JASS:
library DebugLog /* v1.0
*************************************************************************************
*
* Allows you to print messages in Warcraft 3 In-Game and writes them
* inside a .bat file. Run the .bat file and it will download the text document
* where the messages are written. The messages will be written along with the
* elapsed game time. All .bat files will go to Warcraft 3\\Map Errors\\DebugLog
* folder.
*
*************************************************************************************
*
* API
*
* Struct Log extends array
*
* static method add takes string s returns nothing
* - Prints the messages(if ALLOW_PRINT is true) and writes it in the .bat file
*
* static method clear takes nothing returns nothing
* - Clears all written messages
*
* static method update takes nothing returns nothing
* - Creates the .bat file
*
* private static method buffer takes nothing returns nothing
* - Autocreates the file (and updates the document) every 0.031250000 timeout
*
*************************************************************************************
*
* Settings
*
************************************************************************************/
globals
/************************************************
*
* Map Name
* ------------------------------------------
* Put the map's name here.
* This is for you to easily find where
* the log is.
*
************************************************/
private constant string MAP_NAME = "YourMap"
/************************************************
*
* Folder
* ------------------------------------------
* This is where the log will be created
* Recommended not to be touched
*
************************************************/
private constant string LOG_FOLDER = "Map Errors\\DebugLogs\\"
/************************************************
*
* Allow Print
* ------------------------------------------
* Allows you to print messages in-game not
* just outside.
*
************************************************/
private constant boolean ALLOW_PRINT = false
/************************************************
*
* Allow Auto-Update
* ------------------------------------------
* Allows you to update the document
* automatically.
*
************************************************/
private constant boolean ALLOW_AUTO = true
endglobals
/*************************************************************************************
*
* Credits
*
* Doctor Gester
* Magtheridon96
* Geries
* Nestharus
*
*************************************************************************************/
globals
private string array l
private integer i = 0
private timer t = CreateTimer()
private integer mil = 0
private integer sec = 0
private integer min = 0
private string lastRecorded
endglobals
/*****************************************************
*
* Document Header
*
******************************************************/
private function Header takes nothing returns nothing
call Preload("\")\r\n\t echo ************************************************************************************* >> " + MAP_NAME + "Log.txt \r\n\t(\"")
call Preload("\")\r\n\t echo * >> " + MAP_NAME + "Log.txt \r\n\t(\"")
call Preload("\")\r\n\t echo * Warcraft 3 Debug Log >> " + MAP_NAME + "Log.txt \r\n\t(\"")
call Preload("\")\r\n\t echo * >> " + MAP_NAME + "Log.txt \r\n\t(\"")
call Preload("\")\r\n\t echo * Logs of " + MAP_NAME + " >> " + MAP_NAME + "Log.txt \r\n\t(\"")
call Preload("\")\r\n\t echo * >> " + MAP_NAME + "Log.txt \r\n\t(\"")
call Preload("\")\r\n\t echo * -------------------------------------------------------------------------- >> " + MAP_NAME + "Log.txt \r\n\t(\"")
call Preload("\")\r\n\t echo * >> " + MAP_NAME + "Log.txt \r\n\t(\"")
call Preload("\")\r\n\t echo * Statistics: >> " + MAP_NAME + "Log.txt \r\n\t(\"")
call Preload("\")\r\n\t echo * >> " + MAP_NAME + "Log.txt \r\n\t(\"")
call Preload("\")\r\n\t echo * ------------------------------------------ >> " + MAP_NAME + "Log.txt \r\n\t(\"")
call Preload("\")\r\n\t echo * >> " + MAP_NAME + "Log.txt \r\n\t(\"")
call Preload("\")\r\n\t echo * Number of Lines : " + I2S(i) + " >> " + MAP_NAME + "Log.txt \r\n\t(\"")
call Preload("\")\r\n\t echo * Last Recorded Time : " + lastRecorded + " >> " + MAP_NAME + "Log.txt \r\n\t(\"")
call Preload("\")\r\n\t echo * >> " + MAP_NAME + "Log.txt \r\n\t(\"")
call Preload("\")\r\n\t echo * -------------------------------------------------------------------------- >> " + MAP_NAME + "Log.txt \r\n\t(\"")
call Preload("\")\r\n\t echo * >> " + MAP_NAME + "Log.txt \r\n\t(\"")
call Preload("\")\r\n\t echo * Time: Message: >> " + MAP_NAME + "Log.txt \r\n\t(\"")
call Preload("\")\r\n\t echo * >> " + MAP_NAME + "Log.txt \r\n\t(\"")
endfunction
private module Init
private static method onInit takes nothing returns nothing
call init()
endmethod
endmodule
struct Log extends array
static method add takes string s returns nothing
local string mils = I2S(mil)
local string secs = I2S(sec)
if mil < 10 then
set mils = "0" + mils
endif
if sec < 10 then
set secs = "0" + secs
endif
set lastRecorded = "[ " + I2S(min) + " : " + secs + " : " + mils + " ]"
set l[i] = "echo * " + lastRecorded + " : " + s + ">> " + MAP_NAME + "Log.txt "
if ALLOW_PRINT then
call BJDebugMsg(s)
endif
set i = i + 1
endmethod
static method clear takes nothing returns nothing
local integer id = 0
loop
exitwhen i == id
set l[id] = ""
set id = id + 1
endloop
set i = 0
endmethod
static method update takes nothing returns nothing
local integer id = 0
call PreloadGenClear()
call PreloadGenStart()
call Header()
loop
exitwhen id == i
call Preload("\")r\n\t"+ l[i] + "\r\n\t(\"")
set id = id + 1
endloop
call Preload("\")\r\n\t echo * >> " + MAP_NAME + "Log.txt \r\n\t(\"")
call Preload("\")\r\n\t echo ************************************************************************************* >> " + MAP_NAME + "Log.txt \r\n\t(\"")
call Preload("\")\r\n\t start " + MAP_NAME + "Log.txt\r\n\t(\"")
call PreloadGenEnd(LOG_FOLDER + "Download" + MAP_NAME + "Log.bat")
endmethod
private static method buffer takes nothing returns nothing
set mil = mil + R2I(0.031250000 * 100)
if mil > 99 then
set mil = 0
set sec = sec + 1
if sec > 59 then
set sec = 0
set mil = mil + 1
endif
endif
if ALLOW_AUTO then
call Log.update()
endif
endmethod
private static method init takes nothing returns nothing
call TimerStart(t, 0.031250000, true, function Log.buffer)
endmethod
implement Init
endstruct
endlibrary
Last edited: