Basic Event Logging

Basic Event Logging

Any production application should include event logging for troubleshooting and auditing purposes. This code can be placed in any module and called whenever you have an error or event that you want to log.

 Public Function LogEvent(sFileName As String, sEvent As String) As Boolean'**********************************************************************'   Use to log errors or any other events, useful for audits and troubleshooting'   SYNTAX: if LogEvent( app.path & "" & app.title & "Log.txt", "System Exploded") = True then ....'   Bob Feldsien, MSCD'*********************************************************************Dim ff As LongOn Error GoTo ErrHandler       ff = FreeFile    Open sFileName For Append As #ff    '   Will create file if it doesn't already exist    Print #ff, Now() & ": " & sEvent    Close #ff    LogEvent = True    Exit FunctionErrHandler:    LogEvent = False    Exit FunctionEnd Function Public Function DeleteLog(sFileName As String) As Boolean'   Call from Sub Main to recreate file every time app is run'   SYNTAX: DeleteLog app.path & "" & app.title & "Log.txt"    On Error Resume Next    If Dir(sFileName) <> "" Then Kill sFileName    DeleteLog = True    '   if previous line fails, then file didn't exist anywayEnd Function

Share the Post:
data observability

Data Observability Explained

Data is the lifeblood of any successful business, as it is the driving force behind critical decision-making, insight generation, and strategic development. However, due to its intricate nature, ensuring the

Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular