Tracing and Debugging with FesfUtil2

The Debug and Release versions of FesfUtil2 allow you to specify both the debug/tracing level (volume) and locations for output of debug/trace messages (referred to as the debug "mode"). The mode options are: to the console (for console mode programs), to the debugger, to a file, via message box pop-up, or any combination of these simultaneously. While all these modes are supported for Debug builds of the FesfUtil2 libraries, the Release build of the FesfUtil2 libraries only supports logging to the debugger or to a file.

The trace "level" and trace "mode" (that is, where trace output is shown) are controlled via Registry entries. The active level and mode are maintained separately for each application using FesfUtil2 and are read each time an application using the debug version of FesfUtil2 is started.

The values are:

HKLM\Software\OSR\

FEU2DebugMode : REG_DWORD    Where the trace/debug output appears

FEU2TraceLevel     : REG_DWORD    The trace/debug "volume"

 

Supported Values:

      FEU2DebugMode:

0x001       Write messages to a log file

0x002       Write messages to the debugger

0x004       Display message, as it occurs, in a pop-up message box (DEBUG only)

0x100       Write messages to the command window (DEBUG only)

These flags can be or'ed together in any combination.

IMPORTANT: Note that for 32-bit applications (32-bit version of FesfUtil2.dll or 32-bit apps that are statically built with FesfUtil2) the registry key will be reflected to the 32-bit specific registry. So, while HKLM\Software\OSR may have specific values set, 32-bit apps will not see these values. You need to set the values for 32-bit apps under:

\HKLM\SOFTWARE\WOW6432Node\OSR\

When messages are written to a log file, that file is %TMP%\FesfUtil2_<PID>.log. The file is created if it is not already present, and messages are appended to the file if it already exists. The file is opened when an application with logging is started and is closed then the application exits. In Release builds, the file is opened “WRITE_THROUGH.”

Recall that files created in the %TMP% directory on Windows are never automatically deleted. Thus, some thought is needed when enabling logging to a file. Also, because file names use the PID of the application, it’s possible to quickly create a lot of little (potentially empty) trace files. This happens, for example, when you enable logging at the trace level and run one of the sample tools (like SampDir). Every time you run one of the tools, a new log file will be created.

When messages are displayed in a pop-up message box, one message box is popped for each debug message, and it must be dismissed before the app continues. This option can be used from either console mode or windowed programs. It’s most useful when trying to track down a rare issue.

When messages are displayed to the command window, they are written to stdout. This option is only useful if the application has a command window. Setting this flag for a gui app has no effect.

FEU2TraceLevel:

0x001       Trace-level

0x002       Warning-level

0x003       Error-level

0x004       Critical-level

You select one value from the list above, and trace/debug messages at the specified level or higher will be generated (using the mode specified by the FEU2DebugMode parameter). For Release builds, we force any value less than or equal to Trace-level to Warning-level (to prevent a situation where the system is barely responsive in the field by enabling Trace-level debugging, which can be voluminous).