Jump to content

Autoit Debug, Info, Error, Trace, and Event Logging


Recommended Posts

Its been asked before and I can't seem to find any UDF or built in feature with support for Logging in AutoIt, but I thought it wouldn't hurt to ask and spark some focus on the matter.

Applications built for in house use to be run by those that develop them really isn't an issue. It becomes useful to troubleshoot an application if it utilizes some sort of Logging. It is feasible to write functions to support such a need, but I would be pleased if I could find someone who is a far better programmer than I had visited this so I don't have to divert attention and implement it into projects.

What I'm looking for is something similar to NLog or Log4Net with the ability to log events as they happen for ease of troubleshooting if an application fails.

I'm aware of

Opt("GUIOnEventMode", 1)

but that isn't useful if the end user is not the developer and where screenshots are not desired.

I'm not trying to compare Autoit to .NET in any way. I'm just trying to achieve logging capabilities that match those applications mentioned.

I have considered AutoItX and recoding the project in .NET except for the components that are essentially AutoIt only capable, but that is a bit extreme for my immediate needs.

Link to comment
Share on other sites

Func _log($message)
    If $logging Then ; global variable where you can globally switch OFF/ON logging
     FileWriteLine(@ScriptDir & '\file.log', @YEAR & "-" & @MON & "-" & @MDAY & " --> " & $message)
    EndIf
EndFunc

In your source code add calling this function at places where you need logging:

Global $logging = true
 
_log('starting compression ...')
...
_log('compression done.')
Edited by Zedna
Link to comment
Share on other sites

General debug support ...

- See Debug.au3 AutoIt UDF.

- See the ALT-D tool in Scite. (and, if needed, rewrite it a bit to fit your own needs.)

- See alternative debuggers.

Or ... roll your own debugger code.

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

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

×
×
  • Create New...