Debugging/Logging
Statistica now exposes an external logging interface to which external programs can attach. Additional command line parameters can be used to enable this interface to write logging information to a report window or an external text file.
Logging will make entries at significant points in Statistica’s execution, such as program startup, licensing, the statopts.xml path, analysis startup, Spreadsheet/Graph/Report creation, and destructions. Additionally, the logging interface is exposed via SVB, so custom SVB programs can add their own entries to the logging file.
You can set one of four logging levels to control the amount of information reported:
- scNoLogging
- scLogLevelWarning
- scLogLevelLow
- scLogLevelInformational
- scLogLevelDetailed
- scLogLevelCritical
- scLogLevelConfiguration
- scLogEverything
However, when you use DEBUGLOGLib.DbgLog in a macro and inspect the log level options available for the function LogEntry, you see these 8 options:
- scNoLogging
- scLogLevelWarning
- scLogLevelLow
- scLogLevelInformational
- scLogLevelDetailed
- scLogLevelCritical
- scLogLevelConfiguration
- scLogEverything
From the command line: statist -loglevel=1 -logfilename="C:\a.log" -logreport=TRUE
loglevel | Logging level corresponds to the numeric (0 to 3) logging level above. |
logfilepath | Include this parameter if you want to log to a text file. Include the full path name to use for the logging text file. |
logreport | If this parameter is set to TRUE (or 1), a Report window will automatically open in STATISTICA to contain the logging information. It may be used with or without the logfilepath parameter. |
Automation
From automation, include a reference to the "DEBUGLOGLib" found in the type library of "stl_blog.dll" (in the STATISTICA executable directory).
This type library contains one object, DbgLog. You get an instance of this object from the STATISTICA Application.DebugLog method. However, you must first call the Application.DebugLogEnable = True before this object becomes valid. Thus the following VB calls will enable logging, and return a pointer to the DbgLog object:
Dim L As DEBUGLOGLib.DbgLog
A.DebugLogEnable = True
Set L = A.DebugLog
Once you have the DbgLog object, you can access its methods and hook into its events:
LoggingLevel | This property returns/sets the logging level to use. It must be one of the constants to the right | scNoLogging scLogLevelMinimal scLogLevelInformational scLogLevelDetailed |
LoggingFileName | This string property sets the path for a text file to contain the logging information. Only necessary if you intend to enable file logging. | |
FileLogging | Setting this Boolean property to True, enables the event of the DbgLog object. An application can hook into these events and receive the logging messages | |
EventLogging | Setting this Boolean property to True, enables the event of the DbgLog object. An application can hook into these events and receive the logging messages | |
LogEntry(ProcessID As Long, ThreadID as Long, Level As LogLevel, Entry As String |
This method allows an SVB (or external program) to generate entries into the log file. The ProcessID and ThreadID variables are intended to allow you to specify process/thread information from the calling routine; if these are set to 0, then the ProcessID/ThreadID of the DbgLog thread receiving the call will be used. Level is one of the LogLevel values defined, and identifies which logging level this value should be recorded for. Only values that match or exceed the current logging level will be written to the log file or sent to the event. Entry is the string entry. |
scNoLogging scLogLevelMinimal scLogLevelInformational scLogLevelDetailed |
Events interface, IDbgLogEvents:
OnLogEntry(
ProcessId as Long, ThreadId as Long, Time As Double, Level As Long, Entry As String);
When the DbgLog.EventLogging is true, these events will be sent out for each logging message which matches or exceeds the current LoggingLevel. An external application can connect into these events, and record the log entries in their own application.
Here is an example Visual Basic form that starts the Statistica application and hooks into the DbgLog events to display a message box for each log entry. Note that this form would need References defined to the Statistica library (found in statist.exe) and the DEBUGLOGLib (found in stl_blog.dll).
Dim WithEvents L As DEBUGLOGLib.DbgLog
Private Sub Command1_Click()
Dim A As STATISTICA.Application
Set A = CreateObject("STATISTICA.Application")
A.DebugLogEnable = True ' Must do before A.DebugLog
Set L = A.DebugLog
L.LoggingLevel = scLogLevelDetailed
L.EventLogging = True ' Event will be enabled
A.Visible = True
End Sub
Private Sub L_OnLogEntry(ByVal ProcessId As Long, _
ByVal ThreadId As Long, ByVal Time As Double, _
ByVal Level As Long, ByVal Entry As String)
MsgBox "ProcessID:" & CStr(ProcessId) & _
", ThreadID:" & ThreadId & ", Time:" & _
CStr(Time) & ", Level:" & CStr(Level) & vbCrLf & _ Entry
End Sub