Skip to content

EF.Logger

Basic logging services.

TEFLogger class

Central logging service: a singleton (see Instance) that dispatches log messages to the attached endpoints (observers) whenever the message level does not exceed the currently configured LogLevel.

pascal
class constructor Create;

Creates the singleton Instance.

pascal
class destructor Destroy;

Destroys the singleton Instance.

pascal
procedure AfterConstruction;

Sets the log level to its default value.

pascal
property MacroExpansionEngine: TEFMacroExpansionEngine read FMacroExpansionEngine;

The macro expansion engine set by the last Configure call. It is only valid while endpoints are processing the '{ConfigChanged}' notification.

pascal
procedure Configure(const AConfig: TEFTree;

Applies the given configuration: reads the log level from the 'Level' node (accepting 'low', 'medium', 'high', 'detailed', 'debug' or an integer), then notifies observers so that endpoints can reconfigure themselves against AConfig and AMacroExpansionEngine.

pascal
property LogLevel: Integer read FLogLevel write FLogLevel;

Gets or sets the current log level. Messages logged with a level higher than this value are discarded.

pascal
procedure Log(const AString: string;

Logs AString if ALogLevel does not exceed the current LogLevel, by notifying all attached endpoints.

pascal
procedure LogLow(const AString: string);

Logs AString at the LOG_LOW level.

pascal
procedure LogMedium(const AString: string);

Logs AString at the LOG_MEDIUM level.

pascal
procedure LogHigh(const AString: string);

Logs AString at the LOG_HIGH level.

pascal
procedure LogDetailed(const AString: string);

Logs AString at the LOG_DETAILED level.

pascal
procedure LogDebug(const AString: string);

Logs AString at the LOG_DEBUG level.

pascal
procedure LogFmt(const AString: string;

Logs a message built by formatting AString with AParams (see System.SysUtils.Format) at the specified log level.

TEFLogEndpoint class

Abstract base class for logging endpoints. An endpoint attaches itself as an observer of the logger's Instance and writes each notified message to a concrete destination (see the overridden DoLog). Descendants implement the actual output (for example a text file).

pascal
procedure AfterConstruction;

Attaches this endpoint as an observer of the logger's Instance.

pascal
destructor Destroy;

Detaches this endpoint from the logger's Instance.

pascal
procedure UpdateObserver(const ASubject: IEFSubject;

Handles logger notifications: reconfigures the endpoint on '{ConfigChanged}', otherwise writes the context string through DoLog (messages containing 'PASSWORD' are skipped).

Released under Apache License, Version 2.0.