Jump to content

Hi, how to create log files using auto it scripts?


sat6804
 Share

Recommended Posts

Hi All,

How to create log file using auto IT scripts. i used one auto it program but which line error occurs unable to find it,how to find errors, it any error occurs in code the log script should write error scripts lines in particular log file .

If you anyone know please share sample code..

 

Thanks,

Sat6804

Link to comment
Share on other sites

Hi sat6804,

_FileWriteLog

Example from the helpfile:

; Open the logfile in write mode.

#include <File.au3>

Local $hFile = FileOpen(@ScriptDir & "\Example.log", 1)

_FileWriteLog($hFile, "Text 1") ; Write to the logfile passing the filehandle returned by FileOpen.
FileClose($hFile) ; Close the filehandle to release the file.

 

Link to comment
Share on other sites

5 minutes ago, sat6804 said:

Hi ,

Can you please anyone share how to create logfile for entire script to validate and indciate error lines as write log file .

Thanks,

Sat6804

There's no general logging for AutoIt, if you want to log stuff you gotta put in the function l3ill provided (or make your own) at the parts of your script you want to observe.

Please note that this can blow up your script immensely in terms of clarity and amount of lines.

For example:

$go_Connection = _MySQLConnect($gs_MySQLHost, $gs_Database, $gs_User, $gs_Password, $gs_Port, $gs_Driver)
If $go_Connection = False Then
    Exit
EndIf

Becomes:

_Serverlog("STRT", 10, "Server starting up.")
_Serverlog("STRT", 10, "Connecting to MySQL database " & $gs_Database & " on server " & $gs_MySQLHost & "...")
$go_Connection = _MySQLConnect($gs_MySQLHost, $gs_Database, $gs_User, $gs_Password, $gs_Port, $gs_Driver)
If $go_Connection = False Then
    _Serverlog("STRT", 50, "Failed to connect to database.")
    Exit
EndIf
_Serverlog("STRT", 10, "Connection established.")

 

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...