Events are declared in a syntax similar to C structs. The basic template is:
event EVENTNAME {
typeA varname1;
typeB varname2;
...
typeN varnameX;
}
with the various types known to Klogger listed in
Table 1.
Note that the usage of strings is highly discouraged since it requires the use
of buffer copy functions, dramatically increasing the logging overhead (though
strings up to the size of the underlying hardware's cache line are optimized
into simple long assignments).
|
In our SCHEDOUT example, the event will thus be defined as:
event SCHEDOUT {
int pid
}
and will appear in the final text log as:
{
header => {
"type" => "SCHEDOUT",
"serial" => "119",
"timestamp" => "1032071755760",
},
"pid" => "1073",
},
Though extracting the text based log is described in Section 5.2, for now simply note that each event appears as a Perl hash. The hash contains all the fields described in the event definition and a header containing the event type (as text), its serial number in the log and a timestamp taken from the hardware's cycle counter.