littleclown Posted December 15, 2006 Posted December 15, 2006 (edited) Hello. This is my first function and thats why is only 9 lines long. I make it for me, but I believe your opinion and corrections make it better. If someone have another logfile system please show me . Here is the code with example: $logfile=@ScriptDir & "\log-" & @YEAR & @MON & ".txt" func _logs($event,$flag=1) if $flag=1 Then $flag = "INFO" if $flag=2 Then $flag = "WARNING" if $flag=3 Then $flag = "ERROR" $file = FileOpen($logfile,1) $timestamp = @MDAY & "." & @MON & "." & @YEAR &" "&@HOUR&":"&@MIN&":"&@SEC FileWriteLine($file,$timestamp & " - "& $flag & " - " & $event) FileClose($file) EndFunc $del = FileDelete("somefile.txt") if $del Then _logs("Del somefile.txt") Else _logs("Cannot del somefile.txt!",2) EndIf I use this for my scripts coz I am not on the PC when the scrpts working, and I wont to know what happens with them in the next morning Edited December 15, 2006 by littleclown
Stumpii Posted December 15, 2006 Posted December 15, 2006 You could also use the built in function '_FileWriteLog' and add a wrapper for your 'INFO', 'WARNING' and 'ERROR' info. Good start. Take a look in 'File.au3' and see how '_FileWriteLog' is written. Give a man a script; you have helped him for today. Teach a man to script; and you will not have to hear him whine for help.AutoIt4UE - Custom AutoIt toolbar and wordfile for UltraEdit/UEStudio users.AutoIt Graphical Debugger - A graphical debugger for AutoIt.SimMetrics COM Wrapper - Calculate string similarity.
littleclown Posted December 16, 2006 Author Posted December 16, 2006 Hm. I see the _FileWriteLog and its pretty the same . The difference really is the event system. I will write log reader also .
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