ILoggerBase
- Namespace
- ZCore
Base interface for all kinds of loggers. Any logger that should be usable within the libraries of the Zeugwerk Framework has to implement from this interface. Out-of-the-box these are most notably
- LoggerFile7FF and LoggerFile7FFUM for logging into a text file
- LoggerBuffered7FF for logging into a PLC internal buffer
- Messaging for logging alarms into an externally available buffer (i.e. for a HMI)
- Alarming for logging alarms into an externally available buffer (i.e. for a HMI) that is specifically meant for alarms.
- LoggerDecorator for extending all loggers mentioned above via the decorator pattern.
A single log message has the following properties
- LogLevel: Severity of a message
- Timestamp: Timestamp that contains information about when a message was logged
- Message: String that contains the actual information that should be logged.
And can be written by utilizing a predefined logging-method (i.e. Debug, Trace) or the generic method LogMessageRef. While the predefined logging-methods automatically fill most properties of a log message, the generic method give the most control by providing a parameter for every property of a log message.
The method SetLevel and SetLevelRef, respectively, allow to filter messages that are under a defined severity threshold - Logmessages with a Level that is smaller than the level set with this method are ignored.
INTERFACE ILoggerBase
Properties
MinimumLevel
Sets the threshold of logged messages. Logging messages, which have the same severity level or higher will be emitted handled by the logger (others are ignored). The default value for MinimumLevel, which is used when this method is not used to overwrite it, can be parametrized with a library parameter. The MinimumLevel, which is set with this property is for instance only, if the minimum loglevel should be controlled globally for all loggers used in an application, use MinimumLevelRef
Note
Calling this method will unlink the logger instance from the pointer that has been passed with SetLevelRef The Logger uses whatever method was called last.
PROPERTY MinimumLevel : LogLevel
Property Value
MinimumLevelRef
Sets the threshold of logged messages to logLevelRef^
. Since the passed value is a reference, it can be changed at any time externally
and be shared over several loggers.
Logging messages which have the same severity level or higher will be emitted handled by the logger (others are ignored).
The default value for logLevel, which is used when this method is not used to overwrite it, can be parametrized with a
library parameter.
Note
Calling this method will not effect the logLevel that has been set with MinimumLevel. The Logger uses whatever method was called last.
PROPERTY MinimumLevelRef : REFERENCE TO LogLevel
Property Value
- REFERENCE TO LogLevel
Methods
LogMessageRef
This method allows to set every single property of a log message manually. Usually this method should not be used in an application, use one of the specialized methods instead (i.e. Debug, Trace)
The timestamp
property is overwritten by the actual timestamp if timestamp=0
.
METHOD LogMessageRef (
timestamp : ULINT,
text : REFERENCE TO ZString,
logLevel : LogLevel)
Inputs
timestamp
ULINTUnix timestamp of the running PLC target in 1ms resolution
text
REFERENCE TO ZStringDesired information message as ASCII text
logLevel
LogLevelLogLevel based on Apache log4j