Trying to make a cleaner logging system for a script. I need milliseconds and that's proving to be annoying.
Code: Select all
; this works but requires two lines of code EVERY time before it writes to the log file
;which is technically not the exact time of the log, since the time is taken down on the first line, and written to the file on the second line.
FormatTime, TimeString,, MM`/dd`/yyyy hh:mm:ss:%A_MSec%
FileAppend, %TimeString% - logging stuff here that's happening at this time`r`n, C:\scripts\test\log.txt
;this works but requires two lines of code EVERY time before it writes to the log file
;which is technically not the exact time of the log, since the time is taken down on the first line, and written to the file on the second line.
timestring := A_MM . "/" . A_DD . "/" . A_YYYY . " " . A_Hour . ":" . A_Min . ":" . A_Sec . ":" . A_Msec
FileAppend, %TimeString% - logging stuff here that's happening at this time`r`n, C:\scripts\test\log.txt
; this works but looks really ugly and long just to log.
FileAppend, % A_MM . "/" . A_DD . "/" . A_YYYY . " " . A_Hour . ":" . A_Min . ":" . A_Sec . ":" . A_Msec . " - logging stuff here that's happening at this time`r`n", C:\scripts\test\log.txt
; how can I get one line of code that looks good?