You can write template text when you define your events. This template can include qualificators like %1, %2, etc. Qualificator defines variable part of event. Each logged event will contain reference to template's text, so template's text is not stored into log itself (thus, saving storage space). But any dynamic content for qualificators will be stored inside log. When you're viewing log - dynamic content will be inserted into qualificator's positions and form a full error message.
EurekaLog defines two qualificator by default: exception message and full path to bug report file.
You can alter default behavior to store arbitrary dynamic data. You can do this by altering send class. First, you need to declare your own send class which will contain your customizations and register it within EurekaLog:
unit CustomizedSystemLog;
Next, you can alter behavior as you like. For example, default TEventLogDialog class has virtual method FillData with default implementation as follows:
procedure TEventLogDialog.FillData(const AData: TStrings);
which you can override to define your own dynamic content. You can use ExceptionInfo property of dialog class to get access to different properties of logged exception in question. You can also use BugReport property to gain access to bug report content.
The following example defines 4 custom dynamic pieces: %1 for exception message, %2 for exception type, %3 for compact call stack, %4 for BugID.
unit CustomizedSystemLog;
You can use the following .mc file for this example:
MessageIdTypedef=DWORD SeverityNames=(Success=0x0:STATUS_SEVERITY_SUCCESS Informational=0x1:STATUS_SEVERITY_INFORMATIONAL Warning=0x2:STATUS_SEVERITY_WARNING Error=0x3:STATUS_SEVERITY_ERROR ) FacilityNames=(System=0x0:FACILITY_SYSTEM Runtime=0x2:FACILITY_RUNTIME Stubs=0x3:FACILITY_STUBS Io=0x4:FACILITY_IO_ERROR_CODE ) LanguageNames=(English=0x409:MSG00409) MessageId=0x1 Severity=Error Facility=Runtime SymbolicName=mcEurekaLogErrorMessage Language=English There was an exception #%4 of type %2 with message:%n%1%nCall stack:%n%3 .
The result will look like this:
An event with the 4 custom qualificators
Note: you can look at NT Service Application demo which is shipped with EurekaLog.
See also:
|