ILogger
- Namespace
- ZCore
- Extends
- Inherited Properties
- Inherited Methods
INTERFACE ILogger EXTENDS ZCore.ILoggerBase, ZCore.ILoggerImperativeApi, ZCore.ILoggerFluentApi
Base interface for all kinds of loggers. Any logger that should be usable within the libraries of the Zeugwerk Framework have 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)
- LoggerNameDecorator 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 MinimumLevel and MinimumLevelRef, 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.
The interface supports an imperative API, e.g.
logger.Debug('hello world');
logger.Debug(_stringBuilder.Append('hello ').Append('world').ToString());
and also a fluent API, e.g.
logger.AtDebug().LogMessage('hello world');
logger.AtDebug().WithRisingTrigger(boolean1).LogMessage('boolean1 just got true');
logger.AtDebug().WithFallingTrigger(boolean1).LogMessage('boolean1 just got false');
logger.AtDebug().WithCondition(counter > 5).Append('counter exceeds ').AppendInt(5);
While the imperative API is more convienent for simple messages, the fluent API is more flexible with conditions and appending strings.