Jump to content

Log every AUTOIT command for debugging


Recommended Posts

Hi,

I´ve written a Script with many functions to inventory some PC's by a loginprocess.

But now sometimes a funktion hung for too many seconds, but I don't know why!

So. I want to write a debug log witch logs every autoit command by adding a timestamp every line.

Is is possible to create a logfile for every Command??

I can't see the Debuginfo by "Opt("TrayIconDebug", 1)" because it runs while the loginprocess.

At this moment the traybar is not visible jet.

What I need, is a function that writes the Lines to a logfile witch normaly generatet to the trayicon by using

"Opt("TrayIconDebug", 1)"

Example

I want to log the following Function

Func FTP_PUT()
    $server = '100.100.100.100'
    $username = 'test'
    $pass = 'test'
    
    $Open = _FTPOpen('FTP Inventarisierung')
    $Conn = _FTPConnect($Open, $server, $username, $pass)
    $Ftpp = _FtpPutFile($Conn, $AUSGABEFILE, $NAMEFILE)
    $Ftpc = _FTPClose($Open)
    
    EndFunc

The Logfile should look like this

The Date Format for the logfile; yyyy.mm.dd.hh.mm.ss

2006.02.25.07.44.02-> $server = '100.100.100.100'

2006.02.25.07.44.03-> $username = 'test'

2006.02.25.07.44.03-> $pass = 'test'

2006.02.25.07.44.03-> $Open = _FTPOpen('FTP Inventarisierung')

2006.02.25.07.44.05-> $Conn = _FTPConnect($Open, $server, $username, $pass)

2006.02.25.07.44.05-> $Ftpp = _FtpPutFile($Conn, $AUSGABEFILE, $NAMEFILE)

2006.02.25.07.44.07-> $Ftpc = _FTPClose($Open)

I hope You can help me

Wolke

:o

Link to comment
Share on other sites

Far as I know there is no switch/flag to turn on logging for every command, so if you want to log each line you'll have to put the log commands in i.e.

#include <file.au3>
;
Func FTP_PUT()
    $server = '100.100.100.100'
    _FileWriteLog(@ScriptDir & "\my.log","$server = " & $server)

    $username = 'test'
    _FileWriteLog(@ScriptDir & "\my.log","$username = " & $username)

    $pass = 'test'
    _FileWriteLog(@ScriptDir & "\my.log","$pass = " & $pass)
    
    $Open = _FTPOpen('FTP Inventarisierung')
    _FileWriteLog(@ScriptDir & "\my.log","$Open = _FTPOpen('FTP Inventarisierung')")

    $Conn = _FTPConnect($Open, $server, $username, $pass)
    _FileWriteLog(@ScriptDir & "\my.log","$Conn = _FTPConnect($Open, $server, $username, $pass)")

    $Ftpp = _FtpPutFile($Conn, $AUSGABEFILE, $NAMEFILE)
    _FileWriteLog(@ScriptDir & "\my.log","$Ftpp = _FtpPutFile($Conn, $AUSGABEFILE, $NAMEFILE)")

    $Ftpc = _FTPClose($Open)
    _FileWriteLog(@ScriptDir & "\my.log","$Ftpc = _FTPClose($Open)")
    
EndFunc

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

one idea would be to read the au3 file in an array and then use the command line option to execute every command

Func AutoItExecute($Cmd)
   RunWait(@AutoItExe & ' /AutoIt3ExecuteLine "' & $Cmd & '"')
EndFunc
and then you have it write the line that it ran and give a time stamp in the file (_FileWriteLog). I don't know how well this will work for functions and things like that though... what your asking for is not that easy. it would have to be some sort of debug program.

Another thing is, you could use auto it to populate the the _FileWriteLog line in your au3 file. just an idea since you have 1000's lines of code. you could also play with ConsoleWrite. if your a hacker you could look into the mem functions as well.

Good Luck, you will need it!

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...