TPDFlibLogEvent
Data types, document management
Description
TPDFlibLogEvent is the type of the TPDFlibLogger OnLog property. It receives the level, numeric code and message of every record the logger emits, and forms the callback-first half of the logging model; the optional file sink is the other half.
On Delphi the type is a reference to procedure, so an anonymous method or a plain procedure can be assigned. On Free Pascal 3.2 the type is a method pointer instead, so only a procedure of object fits.
Syntax
Delphi
TPDFlibLogEvent = reference To Procedure(Level: TPDFlibLogLevel; Code: Integer;
Const Msg: WideString);Parameters
| Level | Severity of the record: llDebug, llInfo, llWarn or llError |
|---|---|
| Code | Numeric code from the LastErrorCode taxonomy that accompanies the message |
| Msg | Human-readable message text, already formatted by the caller |
Remarks
Free Pascal 3.2 has no anonymous method types, so there the type is declared as Procedure(Level: TPDFlibLogLevel; Code: Integer; Const Msg: WideString) Of Object; assign a plain method of an object in that build.
The logger invokes the callback only after its own level filter, so records below the logger's Level never reach it; a fresh logger starts at llInfo.
The callback receives three arguments only: the trailing extra-fields text accepted by Log is written to the file sink and is not passed on.
Assigning nil disables the callback, and the logger keeps working when only FileName is set.
The logger stores the reference and does not own the target object, so the object behind the method must outlive the logger.
The type is a procedure, so a callback has no result and cannot suppress a record. Nothing serialises the callback itself, so a logger shared between threads needs a thread-safe handler.
The callback runs on the thread that calls Log, which with the parallel renderer can be a worker thread rather than the main thread.