Getting details about the last error

Almost all methods return a Boolean value or an object reference reflecting the success of the operation. You should test this value. If it is "negative" (False respectively Nothing) then an error occurred. To get details about the error you can use the following (property) methods:

§      ITLogLib2.LastErrorCode

§      ITLogLib2.LastErrorDescription

 

Here is an example code snippet (VB6):

 

Private Sub MsgBoxForFailedMethodCall(MethodName As String)

MsgBox "Code: " & ITLogLib2.LastErrorCode _

& ", Description: " & ITLogLib2.LastErrorDescription, _

, "Method " & MethodName & " returned error code."

End Sub

 

Sub Main

If Not ITLogLib2.Initialize(LogAppName, LogCfgFile, LogLicenseKey) _

Then

MsgBoxForFailedMethodCall "Initialize"

End ' exit program

End If

End Sub

 

And here is another:

 

Dim LogChannel As ITOutputLogChannel

Set LogChannel = ITLogLib2.OpenLogChannel("DeveloperLog")

If LogChannel Is Nothing Then

' log this error (in the default logchannel, "StdLog")

QuickLog "LoggingDemo", "Initialize", _

"Couldn't open logchannel 'DeveloperLog'", LEVEL_ERROR

' We continue our program, but output to DeveloperLog will get lost.

End If