FinalVersion Posted April 15, 2009 Share Posted April 15, 2009 Either logs an "Event" or a "Error" Put it in your; C:\Program Files\AutoIt3\Include\ The Command: LogEvent(0 or 1; 0 = event 1 = error, "Your Text Here") Example. ;Example #Include <LogEvent.au3> ;Will only work if you put it in your include directory LogEvent(0, "This Is An Event") Sleep(1000) LogEvent(1, "This Is An Error" & @CRLF) ExitoÝ÷ Ø ÝêÞجjëh×6#cs ---------------------------------------------------------------------------- AutoIt Version: 3.2.13.13 (beta) Author: Godly Script Function: Simple Logging Function #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here Func LogEvent($Code, $String) $LogFile = FileOpen(@ScriptDir & "\Logs.txt", 1) Select Case $Code = 0 FileWriteLine($LogFile, "<Event>" & " " & @Hour & ":" & @Min & ":" & @Sec & " | " & $String) Case $Code = 1 FileWriteLine($LogFile, "<Error>" & " " & @Hour & ":" & @Min & ":" & @Sec & " | " & $String) EndSelect FileClose($LogFile) EndFunc [center][+] Steam GUI [+][+] Clipboard Tool [+][+] System :: Uptime [+][+] StarCraft II Mouse Trap [+][/center] Link to comment Share on other sites More sharing options...
nikink Posted April 16, 2009 Share Posted April 16, 2009 (edited) Nice and simple. Good work! But it might be a bit slow due to all the File Opening, writing and Closing though. Perhaps append to a string and perform one Open, write and Close at the end? EDIT: And having a way to have a unique name for the log file, to prevent multiple scripts from clashing and overwriting? Edited April 16, 2009 by nikink Link to comment Share on other sites More sharing options...
FinalVersion Posted April 16, 2009 Author Share Posted April 16, 2009 Nice and simple. Good work! But it might be a bit slow due to all the File Opening, writing and Closing though. Perhaps append to a string and perform one Open, write and Close at the end?EDIT: And having a way to have a unique name for the log file, to prevent multiple scripts from clashing and overwriting?Feel free to go ahead and edit it, just post what you end up with [center][+] Steam GUI [+][+] Clipboard Tool [+][+] System :: Uptime [+][+] StarCraft II Mouse Trap [+][/center] Link to comment Share on other sites More sharing options...
Valuater Posted April 20, 2009 Share Posted April 20, 2009 Nice effort Godly, however you might want to have a look at this... Func LogEvent($String, $Code = 1) Local $eType = "<Error>", $LogFile = FileOpen(@ScriptDir & "\Logs.txt", 1) If $Code <> 1 Then $eType = "<Event>" FileWriteLine($LogFile, $eType & " " & @Hour & ":" & @Min & ":" & @Sec & " | " & $String) FileClose($LogFile) EndFunc #1 It is a lot of unnecessary work to use "Include" for one Function. #2 The "String" should be first as the "Type" can be 1 constantly with the second parameter changed only when needed. #3 See _FileWriteLog() 8) Link to comment Share on other sites More sharing options...
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