Logger
Controller Logbook
Each controller can hold an unlimited number of controller logs. A controller logbook consists of references to selected local and public variables of the controller.
Global Logbook
The global logbook is a collection of instances of controller logbooks. A controller logbook can be contained in several global logbooks.
Functions
logEntry()
Within a controller, a log entry can be executed with the e function and with the transfer of a controller logbook.
A log entry enters the following variable values into the log system:
- Current variable values of the controller logbook to which the function is applied.
- Variable values of the last task run of all other variables contained in the same global logbook.
logFinalize()
The logFinalize function is used to complete all logfiles for which the corresponding controller logbook is involved.
FileClient Konfiguration
The FileClient configuration defines the way how login information is stored in log files. The FileClient parameters are described in the article FileClient.
As a result of the configuration, a configuration file is created which, together with the software, reaches the control.
Native logger
Logger is also available without Controller Logbook. Use loggerMethods add() to create a new log entry.
Log type
With native log.add() method following log types are available.
LogType : ModelType | MQTT log type name | MQTT log type value | |
---|---|---|---|
error | System alarm | 1 | System alarm supports generic message logging required for platform framework (Exception handling). It is not part of AVM message handler. It is allowed to use system messaging at application for exceptions like NullPointer, DivisionByZero, .... Keep in mind, that system messages could be forwarded to Service Ui Messages |
warning | System warning | 2 | System warning for generic message logging. |
info | System info | 3 | System info for generic message logging. |
statelog | State log | 4 | Use state log carefully. Since data required for state animation. Published separately at log/state topic. |
data | Data | 6 | Use data for specific log entries from application. |
Use Cases
Use Case 1: Cyclical logging of a variable
Create the logbook
Create a controller logbook in the controller definition:
Selecting the variables to be logged:
In a code snippet, call the logEntry function with the controller logbook as a parameter:
Create a 'global' logbook in the Config:
Select the previously created controller logbook in the desired controller instance:
At the point where the model inconsistency is displayed, set a configuration object:
The logbook is now ready to log entries. These entries are also visible in the Weblog client.
Configure Fileclient
In order to save the log entries to a file with the previously created logbook, a file client must be created and connected to the corresponding logbook. To do this, a new 'loggerUsage' of type 'LogbookStorage' must be created:
Select the desired global logbook:
In the newly created fileclient object, the default values can be used, only the template for the display within the logfile has to be set.
With the open template the representation can be freely defined. In addition to the variables that are contained in the logbook, there are also various types available for determining the date and time:
The newly created file client must be assigned to any desired hardware config:
The resulting logfile:
Use Case 2: Log variables from different controllers
The previously created global logbook can be attached to any other controller logbook:
With each call to the logEntry () function on one of the attached controller logs, a complete log entry is made for all log elements.
The variables from the newly added logbooks are also available again in the template configuration:
The resulting logfile: