• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Debug I/O v1.1

  • DebugLog by Almia
    JASS:
    library DebugLog /* v1.1
    *************************************************************************************
    *
    *    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 the desired folder you want
    *    them to be created.
    *
    *************************************************************************************
    *
    *    API
    *
    *    Struct Log extends array
    *
    *        static method write 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 createFile takes nothing returns nothing
    *        - Creates the .bat file
    *
    *        private static method buffer takes nothing returns nothing
    *        - records the elapsed game time
    *        - Auto-creates the file(if ALLOW_PERIODIC is true)
    *
    *************************************************************************************
    *
    *    Notes:
    *
    *        - Messages must be less than 70 characters
    *        - MAP_NAME must not have spaces.
    *        - .bat files will be deleted after downloading the txt file.
    *
    *************************************************************************************
    *
    *    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 = true
    /************************************************
    *
    *    Allow Periodic
    *   ------------------------------------------
    *       Allows you to update the debug file
    *       periodically.
    *
    ************************************************/        
            private constant boolean ALLOW_PERIODIC = true
            private constant real BUFFER = 1.0 // Recommended value
    /************************************************
    *
    *    Print Header
    *   ------------------------------------------
    *       Prints a description header for much
    *       pretty description
    ************************************************/
            private constant boolean PRINT_HEADER = false
        endglobals
    /*************************************************************************************
    *
    *    Credits
    *
    *        Doctor Gester
    *        Magtheridon96
    *        Geries
    *        Nestharus
    *
    *    Testers
    *
    *        Garfield1337
    *        mckill2009
    *        SeriousEnemy
    *
    *************************************************************************************/    
        globals
            private string array l
            private integer i = 0
            private timer t = CreateTimer()
            private real mil = 0
            private integer sec = 0
            private integer min = 0
            private string lastRecorded
            private real looper = 0
        endglobals
        
        /*****************************************************
        *
        *   Document Header
        *
        ******************************************************/
        private function Header takes nothing returns nothing
            call Preload("\")\r\n\techo  ************************************************************************************* >> " + MAP_NAME + "Log.txt \r\n\t(\"")
            call Preload("\")\r\n\techo  *                                                                                     >> " + MAP_NAME + "Log.txt \r\n\t(\"")
            call Preload("\")\r\n\techo  *     Warcraft 3 Debug Log                                                            >> " + MAP_NAME + "Log.txt \r\n\t(\"")
            call Preload("\")\r\n\techo  *                                                                                     >> " + MAP_NAME + "Log.txt \r\n\t(\"")
            call Preload("\")\r\n\techo  *         Logs of " + MAP_NAME + "                                                    >> " + MAP_NAME + "Log.txt \r\n\t(\"")
            call Preload("\")\r\n\techo  *                                                                                     >> " + MAP_NAME + "Log.txt \r\n\t(\"")
            call Preload("\")\r\n\techo  *     --------------------------------------------------------------------------      >> " + MAP_NAME + "Log.txt \r\n\t(\"")
            call Preload("\")\r\n\techo  *                                                                                     >> " + MAP_NAME + "Log.txt \r\n\t(\"")
            call Preload("\")\r\n\techo  *         Statistics:                                                                 >> " + MAP_NAME + "Log.txt \r\n\t(\"")
            call Preload("\")\r\n\techo  *                                                                                     >> " + MAP_NAME + "Log.txt \r\n\t(\"")
            call Preload("\")\r\n\techo  *         ------------------------------------------                                  >> " + MAP_NAME + "Log.txt \r\n\t(\"")
            call Preload("\")\r\n\techo  *                                                                                     >> " + MAP_NAME + "Log.txt \r\n\t(\"")
            call Preload("\")\r\n\techo  *             Number of Lines : " + I2S(i + 1) + "                                    >> " + MAP_NAME + "Log.txt \r\n\t(\"")
            call Preload("\")\r\n\techo  *             Last Recorded Time : " + lastRecorded + "                               >> " + MAP_NAME + "Log.txt \r\n\t(\"")
            call Preload("\")\r\n\techo  *                                                                                     >> " + MAP_NAME + "Log.txt \r\n\t(\"")
            call Preload("\")\r\n\techo  *    --------------------------------------------------------------------------       >> " + MAP_NAME + "Log.txt \r\n\t(\"")
            call Preload("\")\r\n\techo  *                                                                                     >> " + MAP_NAME + "Log.txt \r\n\t(\"")
            call Preload("\")\r\n\techo  *             Time:               Message:                                            >> " + MAP_NAME + "Log.txt \r\n\t(\"")
            call Preload("\")\r\n\techo  *                                                                                     >> " + 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 write takes string s returns nothing
                local string mils = I2S(R2I(mil))
                local string secs = I2S(sec)
                local string mins = I2S(min)
                if mil < 10 then
                    set mils = "0" + mils
                endif
                if sec < 10 then
                    set secs = "0" + secs
                endif
                if min < 10 then
                    set mins = "0" + mins
                endif
                set lastRecorded = "[ " + I2S(min) + " : " + secs + " : " + mils + " ]"
                set l[i] = "\")r\n\techo  *        " + lastRecorded + " : " + s  + ">> " + MAP_NAME + "Log.txt\r\n\t(\""
                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 createFile takes nothing returns nothing
                local integer id = 0
                call PreloadGenClear()
                call PreloadGenStart()
                call Preload("\")\r\n\tDEL " + MAP_NAME + "Log.txt\r\n\t(\"")
                if PRINT_HEADER then
                   call Header()
                endif
                loop
                    exitwhen id == i
                    call Preload(l[id])
                    set id = id + 1
                endloop
                if PRINT_HEADER then
                    call Preload("\")\r\n\techo  *                                                                                     >> " + MAP_NAME + "Log.txt \r\n\t(\"")
                    call Preload("\")\r\n\techo  ************************************************************************************* >> " + MAP_NAME + "Log.txt \r\n\t(\"")
                endif
                call Preload("\")\r\n\tstart " + MAP_NAME + "Log.txt\r\n\t(\"")
                call Preload("\")\r\n\tDEL " + "Download" + MAP_NAME + "Log.bat\r\n\t(\"")
                call PreloadGenEnd(LOG_FOLDER + "Download" + MAP_NAME + "Log.bat")
            endmethod
            
            private static method buffer takes nothing returns nothing
                set mil = mil + 3.125000000
                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_PERIODIC then
                    if looper > BUFFER then
                        set looper = 0
                        call createFile()
                    else
                        set looper = looper + 0.031250000
                    endif
                endif
            endmethod
            
            private static method init takes nothing returns nothing
                call TimerStart(t, 0.031250000, true, function Log.buffer)
            endmethod
            
            implement Init
        endstruct
    endlibrary
  • Demo code: Non-auto create file.
    JASS:
    library Test initializer init uses DebugLog
        globals
            private integer i = 0
        endglobals
        private function test takes nothing returns nothing
            if GetRandomReal(0, 100) > 50 then
                set i = i + 1
                call Log.write("Round Test : " + I2S(i))
                call Log.createFile()
            endif
        endfunction
        
        private function init takes nothing returns nothing
            local integer i = 0
            call Log.write("Test initialized")
            call TimerStart(CreateTimer(), 0.031250000, true, function test)
        endfunction
    endlibrary
    Wait value test with auto-create file
    JASS:
    library Test initializer init uses DebugLog
        globals
            private integer i = 0
            private real value = 0
            private boolean get = false
        endglobals
        private function test takes nothing returns nothing
            set value = value + 0.003125000
            if get then
                call Log.write(R2SW(value, 11, 11))
                set value = 0.0
                set get = false
            endif
        endfunction
        
        private function init takes nothing returns nothing
            call Log.write("Recording Wait values : 0.0 value")
            call Log.write("Number of expected record times : 100")
            call TimerStart(CreateTimer(), 0.003125000, true, function test)
            loop
                exitwhen i == 100
                set i = i + 1
                call TriggerSleepAction(0.0)
                set get = true
            endloop
        endfunction
    endlibrary
  • Results Sample:
    Code:
     *************************************************************************************  
     *                                                                                      
     *     Warcraft 3 Debug Log                                                             
     *                                                                                      
     *         Logs of YourMap                                                     
     *                                                                                      
     *     --------------------------------------------------------------------------       
     *                                                                                      
     *         Statistics:                                                                  
     *                                                                                      
     *         ------------------------------------------                                   
     *                                                                                      
     *             Number of Lines : 139                                         
     *             Last Recorded Time : [ 0 : 08 : 59 ]                                
     *                                                                                      
     *    --------------------------------------------------------------------------        
     *                                                                                      
     *             Time:               Message:                                             
     *                                                                                      
     *        [ 0 : 00 : 00 ] : Test initialized
     *        [ 0 : 00 : 03 ] : Round Test : 
     *        [ 0 : 00 : 59 ] : Round Test : 10
     *        [ 0 : 00 : 62 ] : Round Test : 11
     *        [ 0 : 00 : 71 ] : Round Test : 12
     *        [ 0 : 00 : 75 ] : Round Test : 13
     *        [ 0 : 00 : 81 ] : Round Test : 14
     *        [ 0 : 00 : 87 ] : Round Test : 15
     *        [ 0 : 00 : 90 ] : Round Test : 16
     *        [ 0 : 00 : 93 ] : Round Test : 17
     *        [ 0 : 00 : 96 ] : Round Test : 18
     *        [ 0 : 01 : 06 ] : Round Test : 19
     *        [ 0 : 01 : 09 ] : Round Test : 20
     *        [ 0 : 01 : 12 ] : Round Test : 21
     *        [ 0 : 01 : 15 ] : Round Test : 22
     *        [ 0 : 01 : 18 ] : Round Test : 23
     *        [ 0 : 01 : 21 ] : Round Test : 24
     *        [ 0 : 01 : 25 ] : Round Test : 25
     *        [ 0 : 01 : 34 ] : Round Test : 26
     *        [ 0 : 01 : 40 ] : Round Test : 27
     *        [ 0 : 01 : 50 ] : Round Test : 28
     *        [ 0 : 01 : 53 ] : Round Test : 29
     *        [ 0 : 01 : 56 ] : Round Test : 30
     *        [ 0 : 01 : 65 ] : Round Test : 31
     *        [ 0 : 01 : 68 ] : Round Test : 32
     *        [ 0 : 01 : 78 ] : Round Test : 33
     *        [ 0 : 01 : 84 ] : Round Test : 34
     *        [ 0 : 01 : 93 ] : Round Test : 35
     *        [ 0 : 02 : 00 ] : Round Test : 36
     *        [ 0 : 02 : 03 ] : Round Test : 37
     *        [ 0 : 02 : 06 ] : Round Test : 38
     *        [ 0 : 02 : 21 ] : Round Test : 39
     *        [ 0 : 02 : 28 ] : Round Test : 40
     *        [ 0 : 02 : 40 ] : Round Test : 41
     *        [ 0 : 02 : 43 ] : Round Test : 42
     *        [ 0 : 02 : 46 ] : Round Test : 43
     *        [ 0 : 02 : 50 ] : Round Test : 44
     *        [ 0 : 02 : 56 ] : Round Test : 45
     *        [ 0 : 02 : 65 ] : Round Test : 46
     *        [ 0 : 02 : 81 ] : Round Test : 47
     *        [ 0 : 02 : 84 ] : Round Test : 48
     *        [ 0 : 02 : 90 ] : Round Test : 49
     *        [ 0 : 02 : 93 ] : Round Test : 50
     *        [ 0 : 02 : 96 ] : Round Test : 51
     *        [ 0 : 03 : 03 ] : Round Test : 52
     *        [ 0 : 03 : 15 ] : Round Test : 53
     *        [ 0 : 03 : 21 ] : Round Test : 54
     *        [ 0 : 03 : 25 ] : Round Test : 55
     *        [ 0 : 03 : 34 ] : Round Test : 56
     *        [ 0 : 03 : 46 ] : Round Test : 57
     *        [ 0 : 03 : 50 ] : Round Test : 58
     *        [ 0 : 03 : 53 ] : Round Test : 59
     *        [ 0 : 03 : 62 ] : Round Test : 60
     *        [ 0 : 03 : 65 ] : Round Test : 61
     *        [ 0 : 03 : 81 ] : Round Test : 62
     *        [ 0 : 03 : 84 ] : Round Test : 63
     *        [ 0 : 03 : 90 ] : Round Test : 64
     *        [ 0 : 03 : 93 ] : Round Test : 65
     *        [ 0 : 04 : 12 ] : Round Test : 66
     *        [ 0 : 04 : 15 ] : Round Test : 67
     *        [ 0 : 04 : 18 ] : Round Test : 68
     *        [ 0 : 04 : 21 ] : Round Test : 69
     *        [ 0 : 04 : 28 ] : Round Test : 70
     *        [ 0 : 04 : 31 ] : Round Test : 71
     *        [ 0 : 04 : 50 ] : Round Test : 72
     *        [ 0 : 04 : 53 ] : Round Test : 73
     *        [ 0 : 04 : 62 ] : Round Test : 74
     *        [ 0 : 04 : 68 ] : Round Test : 75
     *        [ 0 : 04 : 75 ] : Round Test : 76
     *        [ 0 : 04 : 81 ] : Round Test : 77
     *        [ 0 : 04 : 87 ] : Round Test : 78
     *        [ 0 : 04 : 93 ] : Round Test : 79
     *        [ 0 : 05 : 09 ] : Round Test : 80
     *        [ 0 : 05 : 12 ] : Round Test : 81
     *        [ 0 : 05 : 18 ] : Round Test : 82
     *        [ 0 : 05 : 25 ] : Round Test : 83
     *        [ 0 : 05 : 28 ] : Round Test : 84
     *        [ 0 : 05 : 31 ] : Round Test : 85
     *        [ 0 : 05 : 34 ] : Round Test : 86
     *        [ 0 : 05 : 37 ] : Round Test : 87
     *        [ 0 : 05 : 40 ] : Round Test : 88
     *        [ 0 : 05 : 50 ] : Round Test : 89
     *        [ 0 : 05 : 53 ] : Round Test : 90
     *        [ 0 : 05 : 56 ] : Round Test : 91
     *        [ 0 : 05 : 65 ] : Round Test : 92
     *        [ 0 : 05 : 68 ] : Round Test : 93
     *        [ 0 : 05 : 78 ] : Round Test : 94
     *        [ 0 : 05 : 93 ] : Round Test : 95
     *        [ 0 : 05 : 96 ] : Round Test : 96
     *        [ 0 : 06 : 03 ] : Round Test : 97
     *        [ 0 : 06 : 15 ] : Round Test : 98
     *        [ 0 : 06 : 18 ] : Round Test : 99
     *        [ 0 : 06 : 25 ] : Round Test : 100
     *        [ 0 : 06 : 40 ] : Round Test : 101
     *        [ 0 : 06 : 50 ] : Round Test : 102
     *        [ 0 : 06 : 53 ] : Round Test : 103
     *        [ 0 : 06 : 87 ] : Round Test : 104
     *        [ 0 : 06 : 93 ] : Round Test : 105
     *        [ 0 : 06 : 96 ] : Round Test : 106
     *        [ 0 : 07 : 00 ] : Round Test : 107
     *        [ 0 : 07 : 06 ] : Round Test : 108
     *        [ 0 : 07 : 12 ] : Round Test : 109
     *        [ 0 : 07 : 15 ] : Round Test : 110
     *        [ 0 : 07 : 18 ] : Round Test : 111
     *        [ 0 : 07 : 21 ] : Round Test : 112
     *        [ 0 : 07 : 25 ] : Round Test : 113
     *        [ 0 : 07 : 28 ] : Round Test : 114
     *        [ 0 : 07 : 31 ] : Round Test : 115
     *        [ 0 : 07 : 43 ] : Round Test : 116
     *        [ 0 : 07 : 46 ] : Round Test : 117
     *        [ 0 : 07 : 53 ] : Round Test : 118
     *        [ 0 : 07 : 56 ] : Round Test : 119
     *        [ 0 : 07 : 62 ] : Round Test : 120
     *        [ 0 : 07 : 65 ] : Round Test : 121
     *        [ 0 : 07 : 68 ] : Round Test : 122
     *        [ 0 : 07 : 71 ] : Round Test : 123
     *        [ 0 : 07 : 75 ] : Round Test : 124
     *        [ 0 : 07 : 78 ] : Round Test : 125
     *        [ 0 : 07 : 84 ] : Round Test : 126
     *        [ 0 : 07 : 87 ] : Round Test : 127
     *        [ 0 : 07 : 90 ] : Round Test : 128
     *        [ 0 : 08 : 06 ] : Round Test : 129
     *        [ 0 : 08 : 09 ] : Round Test : 130
     *        [ 0 : 08 : 15 ] : Round Test : 131
     *        [ 0 : 08 : 18 ] : Round Test : 132
     *        [ 0 : 08 : 21 ] : Round Test : 133
     *        [ 0 : 08 : 25 ] : Round Test : 134
     *        [ 0 : 08 : 43 ] : Round Test : 135
     *        [ 0 : 08 : 46 ] : Round Test : 136
     *        [ 0 : 08 : 53 ] : Round Test : 137
     *        [ 0 : 08 : 59 ] : Round Test : 138
     *                                                                                      
     *************************************************************************************
    Random Integer's Sequence
    Code:
     *************************************************************************************  
     *                                                                                      
     *     Warcraft 3 Debug Log                                                             
     *                                                                                      
     *         Logs of YourMap                                                     
     *                                                                                      
     *     --------------------------------------------------------------------------       
     *                                                                                      
     *         Statistics:                                                                  
     *                                                                                      
     *         ------------------------------------------                                   
     *                                                                                      
     *             Number of Lines : 108                                         
     *             Last Recorded Time : [ 0 : 06 : 15 ]                                
     *                                                                                      
     *    --------------------------------------------------------------------------        
     *                                                                                      
     *             Time:               Message:                                             
     *                                                                                      
     *        [ 0 : 00 : 00 ] : Test initialized
     *        [ 0 : 00 : 03 ] : Random Integer Sequence : 78
     *        [ 0 : 00 : 06 ] : Random Integer Sequence : 67
     *        [ 0 : 00 : 09 ] : Random Integer Sequence : 54
     *        [ 0 : 00 : 15 ] : Random Integer Sequence : 87
     *        [ 0 : 00 : 21 ] : Random Integer Sequence : 93
     *        [ 0 : 00 : 25 ] : Random Integer Sequence : 76
     *        [ 0 : 00 : 28 ] : Random Integer Sequence : 62
     *        [ 0 : 00 : 37 ] : Random Integer Sequence : 60
     *        [ 0 : 00 : 43 ] : Random Integer Sequence : 82
     *        [ 0 : 00 : 71 ] : Random Integer Sequence : 87
     *        [ 0 : 00 : 75 ] : Random Integer Sequence : 80
     *        [ 0 : 00 : 81 ] : Random Integer Sequence : 73
     *        [ 0 : 00 : 90 ] : Random Integer Sequence : 88
     *        [ 0 : 01 : 03 ] : Random Integer Sequence : 51
     *        [ 0 : 01 : 09 ] : Random Integer Sequence : 60
     *        [ 0 : 01 : 18 ] : Random Integer Sequence : 58
     *        [ 0 : 01 : 21 ] : Random Integer Sequence : 83
     *        [ 0 : 01 : 25 ] : Random Integer Sequence : 55
     *        [ 0 : 01 : 31 ] : Random Integer Sequence : 80
     *        [ 0 : 01 : 37 ] : Random Integer Sequence : 91
     *        [ 0 : 01 : 40 ] : Random Integer Sequence : 93
     *        [ 0 : 01 : 50 ] : Random Integer Sequence : 92
     *        [ 0 : 01 : 59 ] : Random Integer Sequence : 64
     *        [ 0 : 01 : 65 ] : Random Integer Sequence : 69
     *        [ 0 : 01 : 68 ] : Random Integer Sequence : 91
     *        [ 0 : 01 : 71 ] : Random Integer Sequence : 95
     *        [ 0 : 01 : 75 ] : Random Integer Sequence : 66
     *        [ 0 : 01 : 93 ] : Random Integer Sequence : 69
     *        [ 0 : 01 : 96 ] : Random Integer Sequence : 79
     *        [ 0 : 02 : 00 ] : Random Integer Sequence : 87
     *        [ 0 : 02 : 03 ] : Random Integer Sequence : 96
     *        [ 0 : 02 : 06 ] : Random Integer Sequence : 65
     *        [ 0 : 02 : 12 ] : Random Integer Sequence : 100
     *        [ 0 : 02 : 15 ] : Random Integer Sequence : 89
     *        [ 0 : 02 : 21 ] : Random Integer Sequence : 87
     *        [ 0 : 02 : 25 ] : Random Integer Sequence : 98
     *        [ 0 : 02 : 28 ] : Random Integer Sequence : 100
     *        [ 0 : 02 : 37 ] : Random Integer Sequence : 73
     *        [ 0 : 02 : 43 ] : Random Integer Sequence : 84
     *        [ 0 : 02 : 50 ] : Random Integer Sequence : 62
     *        [ 0 : 02 : 53 ] : Random Integer Sequence : 70
     *        [ 0 : 02 : 56 ] : Random Integer Sequence : 77
     *        [ 0 : 02 : 59 ] : Random Integer Sequence : 53
     *        [ 0 : 02 : 65 ] : Random Integer Sequence : 61
     *        [ 0 : 02 : 68 ] : Random Integer Sequence : 56
     *        [ 0 : 02 : 71 ] : Random Integer Sequence : 88
     *        [ 0 : 02 : 81 ] : Random Integer Sequence : 98
     *        [ 0 : 02 : 84 ] : Random Integer Sequence : 78
     *        [ 0 : 02 : 87 ] : Random Integer Sequence : 84
     *        [ 0 : 03 : 03 ] : Random Integer Sequence : 69
     *        [ 0 : 03 : 12 ] : Random Integer Sequence : 64
     *        [ 0 : 03 : 15 ] : Random Integer Sequence : 91
     *        [ 0 : 03 : 21 ] : Random Integer Sequence : 79
     *        [ 0 : 03 : 25 ] : Random Integer Sequence : 53
     *        [ 0 : 03 : 34 ] : Random Integer Sequence : 80
     *        [ 0 : 03 : 37 ] : Random Integer Sequence : 53
     *        [ 0 : 03 : 43 ] : Random Integer Sequence : 80
     *        [ 0 : 03 : 50 ] : Random Integer Sequence : 65
     *        [ 0 : 03 : 53 ] : Random Integer Sequence : 81
     *        [ 0 : 03 : 56 ] : Random Integer Sequence : 69
     *        [ 0 : 03 : 68 ] : Random Integer Sequence : 69
     *        [ 0 : 03 : 71 ] : Random Integer Sequence : 73
     *        [ 0 : 03 : 78 ] : Random Integer Sequence : 75
     *        [ 0 : 03 : 81 ] : Random Integer Sequence : 70
     *        [ 0 : 03 : 90 ] : Random Integer Sequence : 57
     *        [ 0 : 03 : 96 ] : Random Integer Sequence : 56
     *        [ 0 : 04 : 15 ] : Random Integer Sequence : 64
     *        [ 0 : 04 : 18 ] : Random Integer Sequence : 79
     *        [ 0 : 04 : 25 ] : Random Integer Sequence : 57
     *        [ 0 : 04 : 28 ] : Random Integer Sequence : 94
     *        [ 0 : 04 : 31 ] : Random Integer Sequence : 71
     *        [ 0 : 04 : 40 ] : Random Integer Sequence : 91
     *        [ 0 : 04 : 43 ] : Random Integer Sequence : 55
     *        [ 0 : 04 : 50 ] : Random Integer Sequence : 78
     *        [ 0 : 04 : 53 ] : Random Integer Sequence : 56
     *        [ 0 : 04 : 56 ] : Random Integer Sequence : 57
     *        [ 0 : 04 : 59 ] : Random Integer Sequence : 58
     *        [ 0 : 04 : 62 ] : Random Integer Sequence : 83
     *        [ 0 : 04 : 65 ] : Random Integer Sequence : 90
     *        [ 0 : 04 : 71 ] : Random Integer Sequence : 78
     *        [ 0 : 04 : 75 ] : Random Integer Sequence : 53
     *        [ 0 : 04 : 78 ] : Random Integer Sequence : 92
     *        [ 0 : 04 : 81 ] : Random Integer Sequence : 58
     *        [ 0 : 04 : 84 ] : Random Integer Sequence : 76
     *        [ 0 : 05 : 00 ] : Random Integer Sequence : 90
     *        [ 0 : 05 : 03 ] : Random Integer Sequence : 85
     *        [ 0 : 05 : 09 ] : Random Integer Sequence : 63
     *        [ 0 : 05 : 12 ] : Random Integer Sequence : 67
     *        [ 0 : 05 : 15 ] : Random Integer Sequence : 96
     *        [ 0 : 05 : 18 ] : Random Integer Sequence : 75
     *        [ 0 : 05 : 21 ] : Random Integer Sequence : 86
     *        [ 0 : 05 : 25 ] : Random Integer Sequence : 64
     *        [ 0 : 05 : 28 ] : Random Integer Sequence : 59
     *        [ 0 : 05 : 37 ] : Random Integer Sequence : 59
     *        [ 0 : 05 : 59 ] : Random Integer Sequence : 65
     *        [ 0 : 05 : 62 ] : Random Integer Sequence : 67
     *        [ 0 : 05 : 65 ] : Random Integer Sequence : 65
     *        [ 0 : 05 : 71 ] : Random Integer Sequence : 77
     *        [ 0 : 05 : 75 ] : Random Integer Sequence : 75
     *        [ 0 : 05 : 78 ] : Random Integer Sequence : 53
     *        [ 0 : 05 : 84 ] : Random Integer Sequence : 62
     *        [ 0 : 05 : 87 ] : Random Integer Sequence : 96
     *        [ 0 : 05 : 90 ] : Random Integer Sequence : 90
     *        [ 0 : 05 : 93 ] : Random Integer Sequence : 79
     *        [ 0 : 05 : 96 ] : Random Integer Sequence : 90
     *        [ 0 : 06 : 09 ] : Random Integer Sequence : 75
     *        [ 0 : 06 : 15 ] : Random Integer Sequence : 71
     *                                                                                      
     *************************************************************************************
    TSA values:
    Code:
     *************************************************************************************  
     *                                                                                      
     *     Warcraft 3 Debug Log                                                             
     *                                                                                      
     *         Logs of YourMap                                                     
     *                                                                                      
     *     --------------------------------------------------------------------------       
     *                                                                                      
     *         Statistics:                                                                  
     *                                                                                      
     *         ------------------------------------------                                   
     *                                                                                      
     *             Number of Lines : 101                                     
     *             Last Recorded Time : [ 0 : 11 : 18 ]                                
     *                                                                                      
     *    --------------------------------------------------------------------------        
     *                                                                                      
     *             Time:               Message:                                             
     *                                                                                      
     *        [ 0 : 00 : 00 ] : Recording Wait values : 0.0 value
     *        [ 0 : 00 : 00 ] : Number of expected record times : 100
     *        [ 0 : 00 : 09 ] :  0.103124920
     *        [ 0 : 00 : 15 ] :  0.074999944
     *        [ 0 : 00 : 25 ] :  0.099999920
     *        [ 0 : 00 : 37 ] :  0.099999920
     *        [ 0 : 00 : 50 ] :  0.124999896
     *        [ 0 : 00 : 59 ] :  0.099999920
     *        [ 0 : 00 : 68 ] :  0.099999920
     *        [ 0 : 00 : 78 ] :  0.099999920
     *        [ 0 : 00 : 87 ] :  0.074999944
     *        [ 0 : 01 : 00 ] :  0.124999896
     *        [ 0 : 01 : 09 ] :  0.099999920
     *        [ 0 : 01 : 18 ] :  0.099999920
     *        [ 0 : 01 : 28 ] :  0.099999920
     *        [ 0 : 01 : 40 ] :  0.124999896
     *        [ 0 : 01 : 50 ] :  0.074999944
     *        [ 0 : 01 : 59 ] :  0.099999920
     *        [ 0 : 01 : 68 ] :  0.099999920
     *        [ 0 : 01 : 78 ] :  0.099999920
     *        [ 0 : 01 : 90 ] :  0.124999896
     *        [ 0 : 02 : 00 ] :  0.074999944
     *        [ 0 : 02 : 09 ] :  0.099999920
     *        [ 0 : 02 : 21 ] :  0.124999896
     *        [ 0 : 02 : 31 ] :  0.099999920
     *        [ 0 : 02 : 40 ] :  0.099999920
     *        [ 0 : 02 : 50 ] :  0.099999920
     *        [ 0 : 02 : 62 ] :  0.099999920
     *        [ 0 : 02 : 71 ] :  0.099999920
     *        [ 0 : 02 : 81 ] :  0.099999920
     *        [ 0 : 02 : 90 ] :  0.099999920
     *        [ 0 : 03 : 00 ] :  0.099999920
     *        [ 0 : 03 : 12 ] :  0.099999920
     *        [ 0 : 03 : 21 ] :  0.099999920
     *        [ 0 : 03 : 34 ] :  0.124999896
     *        [ 0 : 03 : 43 ] :  0.099999920
     *        [ 0 : 03 : 62 ] :  0.174999840
     *        [ 0 : 03 : 71 ] :  0.099999920
     *        [ 0 : 03 : 84 ] :  0.124999896
     *        [ 0 : 03 : 90 ] :  0.074999944
     *        [ 0 : 04 : 03 ] :  0.124999896
     *        [ 0 : 04 : 12 ] :  0.099999920
     *        [ 0 : 04 : 25 ] :  0.099999920
     *        [ 0 : 04 : 37 ] :  0.124999896
     *        [ 0 : 04 : 53 ] :  0.174999840
     *        [ 0 : 04 : 62 ] :  0.099999920
     *        [ 0 : 04 : 75 ] :  0.099999920
     *        [ 0 : 04 : 84 ] :  0.099999920
     *        [ 0 : 04 : 96 ] :  0.124999896
     *        [ 0 : 05 : 06 ] :  0.099999920
     *        [ 0 : 05 : 15 ] :  0.099999920
     *        [ 0 : 05 : 25 ] :  0.099999920
     *        [ 0 : 05 : 46 ] :  0.199999824
     *        [ 0 : 05 : 56 ] :  0.099999920
     *        [ 0 : 05 : 65 ] :  0.099999920
     *        [ 0 : 05 : 78 ] :  0.124999896
     *        [ 0 : 05 : 96 ] :  0.174999840
     *        [ 0 : 06 : 06 ] :  0.099999920
     *        [ 0 : 06 : 15 ] :  0.099999920
     *        [ 0 : 06 : 25 ] :  0.099999920
     *        [ 0 : 06 : 37 ] :  0.099999920
     *        [ 0 : 06 : 50 ] :  0.124999896
     *        [ 0 : 06 : 65 ] :  0.174999840
     *        [ 0 : 06 : 75 ] :  0.099999920
     *        [ 0 : 06 : 87 ] :  0.099999920
     *        [ 0 : 06 : 96 ] :  0.099999920
     *        [ 0 : 07 : 09 ] :  0.124999896
     *        [ 0 : 07 : 18 ] :  0.099999920
     *        [ 0 : 07 : 37 ] :  0.174999840
     *        [ 0 : 07 : 46 ] :  0.099999920
     *        [ 0 : 07 : 56 ] :  0.099999920
     *        [ 0 : 07 : 65 ] :  0.099999920
     *        [ 0 : 07 : 78 ] :  0.124999896
     *        [ 0 : 07 : 87 ] :  0.099999920
     *        [ 0 : 08 : 09 ] :  0.199999824
     *        [ 0 : 08 : 25 ] :  0.174999840
     *        [ 0 : 08 : 37 ] :  0.099999920
     *        [ 0 : 08 : 50 ] :  0.124999896
     *        [ 0 : 08 : 59 ] :  0.099999920
     *        [ 0 : 08 : 68 ] :  0.099999920
     *        [ 0 : 08 : 87 ] :  0.174999840
     *        [ 0 : 08 : 96 ] :  0.099999920
     *        [ 0 : 09 : 09 ] :  0.124999896
     *        [ 0 : 09 : 18 ] :  0.099999920
     *        [ 0 : 09 : 28 ] :  0.099999920
     *        [ 0 : 09 : 37 ] :  0.099999920
     *        [ 0 : 09 : 59 ] :  0.199999824
     *        [ 0 : 09 : 65 ] :  0.074999944
     *        [ 0 : 09 : 78 ] :  0.124999896
     *        [ 0 : 09 : 87 ] :  0.099999920
     *        [ 0 : 10 : 00 ] :  0.099999920
     *        [ 0 : 10 : 09 ] :  0.099999920
     *        [ 0 : 10 : 18 ] :  0.099999920
     *        [ 0 : 10 : 37 ] :  0.174999840
     *        [ 0 : 10 : 50 ] :  0.124999896
     *        [ 0 : 10 : 59 ] :  0.099999920
     *        [ 0 : 10 : 71 ] :  0.124999896
     *        [ 0 : 10 : 87 ] :  0.174999840
     *        [ 0 : 11 : 09 ] :  0.199999824
     *        [ 0 : 11 : 18 ] :  0.099999920
     *                                                                                      
     *************************************************************************************
  • Why use .bat file instead of .txt file?
    Answer:
    if i use txt file,the results will look like this:
    Code:
    call Preload("\")
    Message Test
    (\"")
    call Preload("\")
    Hello :3
    (\"")
    Ugly and messy right?
    But the .bat file cleans it.Bat file works with command prompt.The messages will be called by "echo" and will insert it inside the text file,making it more readable and clean.
Contents

DebugLog (Map)

Reviews
19:28, 15th May 2013 Magtheridon96: Good logging tool.

Moderator

M

Moderator

19:28, 15th May 2013
Magtheridon96: Good logging tool.
 
Level 13
Joined
Sep 13, 2010
Messages
550
Actually, no, leave it Debug Log or similar to that. Debug IO sounds stupid, and nobody searches for that name, what they will search for is probably Debug log, Debug File, Log file, or something like that, not Debug IO. Also this is just output.

I don't know what the hell did your code do to warcraft, but it turned it into multithreaded and used almost 2 cores on full load( 80% ) which tells the script is quite not effective, even in your test map it wasn't printing out that intensively. Other thing I noticed is that update( ) function never ends, it is public, so calling it in an another function causes rest code never getting executed. I don't know what's the reason of that, since thread crash shouldn't happen( at first, when there's not so many log entries ), maybe some Preload( ) is missing " somewhere, but this is a major issue with the code.

Also, I really recommend you to NOT update existing log data file, cause right now you need to store all log entries to write them out at next update again. Since you use an array to store those entries, that is quite limited. Instead I recommend to buffer log entries and dump them on next update( ) into a new log-data files. Update should occur after 30-60 seconds, or after 100/200 log entries. This way you'd decrease time spent on writing log, cause you'd have to write new entries only. Three minor cons this method has: There will be a lot data files on intensive use, you need more advanced .bat and script that can handle them, if a player quits all log text after the last update will be missing for him.

That's all for now, but I like the idea of debug files, so once it is fully working, I'll be quite happy.
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
I see you do not write lines immediately. PreloadGenEnd is slow because Wc3 buffers all the Preload lines and then creates a wholly new file on every PreloadGenEnd instead of appending. Still, to test for fatal errors/desyncs, pushing back updates is no option since fatals halt everything. So maybe provide an alternative write option.

What I wanted to generally ask though, any chance to speed up writing to a file? One could erase prior lines again after a block has been completed but this requires to re-equip the preload-buffer like you do at the moment, therefore takes performance on its own and you are likely to reach limits. It should be better to move to another file at a certain amount of lines. Then you do not have to reload as much, wc3 does not need to replace large files and do not have to worry about the oplimit.
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
So you want me to do a File IO-like functionality? Nononononoononononoonononoononononononononoononononoononononononono

Nononononoononononoonononoononononononononoononononoononononononono, I did not.

I mentioned the situation provided by wc3. It's too slow to log large amounts of information. Then I remarked that the functionality shown here is not suited for testing critical errors, therefore made a suggestion.

Independent from your resource - although it may also be improved this way - I pointed out that splitting the output is more effective. Your batch can even remerge all the outputs afterwards. Above all, I am interested in hearing more ideas about speeding up the process.
 
Last edited:
Level 26
Joined
Aug 18, 2009
Messages
4,097
Another idea: It is often ugly to spam the screen ingame with debug game messages. And if you put it away somewhere in quests or some multiboard, then you are very limited or lack the fast access while playing. Therefore I am now using this, outsourcing debug messages in txt files, in conjunction with a parallel running program that redirects the results to stdout of a cmd.exe. So I start the game, a central file is set in the beginning to indicate what map/session you are playing in order to identify where the debugs are stored. Then you call the aiding tool that periodically reads the contents there and prints new entries. Of course wc3 should be windowed so you can see both. Or you have a 2nd monitor. Also, debug msgs should contain a timestamp and you see the timer in the game permanently.
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
Mag updated it, it was nothing big tho, the script as is is working buglessly, but the examples were bugged a bit:
They were requiring nonexisting, DebugIO library
The second example was trying to call nonexisting method .add instead of .write
 
Level 13
Joined
Mar 19, 2010
Messages
870
Wow, this is really cool. I'll add this to our project to get a better Feedback from the users. They just have to paste the debug-log in our Bugs-Forum and we can see what happens...

Greate System!!! Thx a lot! I'll add you to the Credit List if you want?!? The project i mean you'll find in my signature.
 
Level 9
Joined
Dec 12, 2007
Messages
489
This really helps for debugging process though becoming a huge workload to implement to almost finished map.

it would be better if you explain each API further rather than short explanation.

why not make use of static if when using constant boolean?

is there's any limitation?

I come across some strange things, a log shows about 3000 lines yet it only display about 10 lines in the log.
Just found that I can't use | and > in Log.write

it seems to be there is mistype over here:
JASS:
                if sec > 59 then
                    set sec = 0
                    set mil = mil + 1
                endif
it should be:
JASS:
                if sec > 59 then
                    set sec = 0
                    set min = min + 1
                endif

from what I manage to understand from the code,
the log is limited to 8190 lines because of max array size,
and because of the periodic .createfile() which by default reads a growing amount of string array every second, it started to lag after about one minute in game.
and we can't use .clear() to free up the string array as it will clear the next created log file too.
could you set the script to workaround this current limitation? especially the amount of lines and growing string array.
 
Last edited:
Top