MathewThomas Posted February 9, 2017 Posted February 9, 2017 Hi I have created a test autoit Script and am running it through SCiTe. THe script executes fine but I want to capture logs so that I can track it incase the automation fails or has any errors. I can write custom messages or text to a file but I want to capture output that appearrs in the console. I have attached a screenshot of the logs I intend to capture. I want to log messages that appear in the output window over here to a text file.
Moderators JLogan3o13 Posted February 9, 2017 Moderators Posted February 9, 2017 @MathewThomas our forum has a pretty good search feature, something worth trying before you post. You can also look through the help file for suggestions. _FileWriteLog, for example, can write out to a log file for you. You could also use the _EventLog__* functions to use the Windows Event logs for your application. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
MathewThomas Posted February 9, 2017 Author Posted February 9, 2017 HI @JLogan3o13 I did search the forum and could not find a solution to what I am looking to do. THe FWritelog function just writes text that the user specifies to a log file. I am trying to find a way to write the messages that appear in the output window to a file.
Moderators JLogan3o13 Posted February 9, 2017 Moderators Posted February 9, 2017 So rather than a picture (pictures are for Facebook) how about posting some code that shows what you're trying to do. Do you mean you're trying to automatically capture STDOut, or you want to capture everything in the console, time of completion, run time, etc? "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
MathewThomas Posted February 9, 2017 Author Posted February 9, 2017 Yes I need to capture everything that appears in the console. Sometimes there are errors too which pop there which I need to write to a file. The picture above shows the section of output I am referring to.
Moderators JLogan3o13 Posted February 9, 2017 Moderators Posted February 9, 2017 I seem to recall LazyCat doing something like this years ago; you might search the forum for DConsole. The only other way I could think of is to try a ControlGetText on the Console pane, but still think it is not a great idea. You should code in such a way you're catching errors on purpose, not just grabbing everything. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
Starf0x Posted February 10, 2017 Posted February 10, 2017 I use: #include <File.au3> Func _WriteErrorLog($ErrorMessage) Local $Logfile = @WorkingDir & "\" & @ScriptName & ".log" Local $errorFile = $Logfile Local $LogTime = @HOUR & ":" & @MIN & ":" & @SEC Local $hFileOpen = FileOpen($errorFile, 9) FileWriteLine($hFileOpen, $LogTime & " " & $ErrorMessage & @CRLF) FileClose($hFileOpen) EndFunc ;==>WriteErrorLog Cheers, Starf0x
Moderators JLogan3o13 Posted February 10, 2017 Moderators Posted February 10, 2017 @Starf0x, a couple of things: Your script doesn't do what the OP is asking (capture the entirety of the SciTE output pane) Why do you declare a variable for the log file ($Logfile), only to declare it all over again in the very next line ($errorfile)? Your entire function could be boiled down to a single line (two if you want to declare the filename in a variable) and without the need for the include: _WriteErrorLog("Boy this is less code") Func _WriteErrorLog($ErrorMessage) FileWriteLine(@ScriptDir & "\" & @ScriptName & ".log", @HOUR & ":" & @MIN & ":" & @SEC & ": " & $ErrorMessage) EndFunc ;==>WriteErrorLog "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now