How Does the Logbook Work?
The logbook uses COM+ events to pass the information collected
from the application to the logbook components. The components (the
HTML and XML versions) implement the ILogbook
interface (see Figure A-3), a custom
interface with methods corresponding to what is being
logged—method call, event, or error. The
ILogbook
interface is defined as:
interface ILogbook : IUnknown
{
typedef struct tagLOG_ENTRY
{
HRESULT hres;
DWORD dwErrorCode;
DWORD dwProcessID;
DWORD dwThreadID;
GUID guidActivityID;
GUID guidTransactionID;
GUID guidContextID;
BSTR bstrMachineName;
BSTR bstrSourceFileName;
BSTR bstrModuleName;
BSTR bstrMethodName;
DWORD dwLineNumber;
BSTR bstrDescription;
IID iidError;
FILETIME eventTime;
}LOG_ENTRY;
HRESULT LogError ([in]LOG_ENTRY* pErrorEntry);
HRESULT LogMethod([in]LOG_ENTRY* pMethodEntry);
HRESULT LogEvent ([in]LOG_ENTRY* pEventEntry);
};The helper macros collect the information on the application side,
pack it into a
LOG_ENTRY
struct, create a COM+ event class
that implements ILogbook, and fire the appropriate
event. The logbook receives the event, formats it appropriately (to
HTML or XML), and writes it to the log file.
Deciding to use COM+ events was the easy part of the design. Deciding how to channel all the events to the same logbook component and how to collect all the tracing information you are interested in is more challenging.
To solve the first challenge, you can use COM+ instance managements services. The components in the logbook ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access