Jump to content
Sign in to follow this  
JohnBailey

Error Logging

Recommended Posts

JohnBailey

I want to build a log of all accessed lines in a script. Basically, I want a log file of what Opt("TrayIconDebug", 1) does.

; --- Error Watching --- ;
watchforErrors()
AdlibEnable("watchforErrors",5)
Local $hfile = ".\logs\"&@ScriptName&"_log.txt"
Local $created = 0
Local $initial = 0

Func watchforErrors()
    $fileExists = FileExists($hfile)
    If $fileExists = 1 Then
        If $initial = 0 Then 
            FileDelete ($hfile)
            $initial = $initial + 1
        EndIf
        FileOpen($hfile, 1)
        $write = FileWriteLine($hfile, $scriptActivated)
        FileClose($hfile)
    Else
        DirCreate (".\logs")
        _FileCreate ($hfile)
    EndIf
    ;// --- ONE FOR THIS OPERATION --- ;
    If WinExists("Error!") OR WinActive("Error!") Then
        failed("login","Used Adlib","")
    EndIf
EndFunc

; --- -------------- --- ;

A decision is a powerful thing

Share this post


Link to post
Share on other sites
JohnBailey

Haha, I guess I am more ashamed because I'm not sure what the Services include does. I've looked at the AU3 files (Thanks BTW), but I'm not sure I understand what it does.

I actually found out what my problem was (the self correction had a space in the file name GRRR) :whistle: One of those days I suppose :). Nonetheless, it would be fabulous to have a report (txt file) on the script lines accessed like the Opt("TrayIconDebug", 1) does for the Tray. This may be silly, but sometimes I just want to know all of what a file was doing and seeing the lines accessed (even with all the reaccessing considering function useage) can be so helpful.

I just want a txt file of all lines ran. There may be a MUCH better way to do this (eg Services). I just don't know. Thanks!


A decision is a powerful thing

Share this post


Link to post
Share on other sites
evilertoaster

i dont think you want to do that but here's how it can be done---

$a=1

FileWriteLine(@ScriptDir & "\Debug.txt",'$a=1')

MsgBox(0,"HI!","Im doing somthing!")

FileWriteLine(@ScriptDir & "\Debug.txt",'MsgBox(0,"HI!","Im doing somthing!")')

$b=$a+1

FileWriteLine(@ScriptDir & "\Debug.txt",'$b=$a+1')

just add a filewrite after each line of code that has the line of code before it....

Share this post


Link to post
Share on other sites
JohnBailey

evilertoaster, thank you. Yeah, you're right. I don't want to do that (it doubles the amount of time and the file size). I was hoping it could be done via adlib or something.

Where can I research further into what a Service is in regards to AUIT ?

Thanks again for all the patiences and guidance


A decision is a powerful thing

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.