• User guide
  • API Reference
Show / Hide Table of Contents
  • TcLogLib
    • Constants
      • Constants
    • Logger
      • TcLog
      • TcLogCore
      • TcLogTrig
      • ErrorCodes
      • LogLevels
      • RollingIntervals
      • Error
      • LoggingConfiguration
      • ILog
      • ILogCore
    • Utils
      • AnyToString
      • DateTime

TcLog

Implements
TcLogLib.ILog
Namespace: TcLogLib
Declaration
{attribute 'hide_all_locals'}
{attribute 'reflection'}
FUNCTION_BLOCK TcLog IMPLEMENTS TcLogLib.ILog

TcLog is the client side of the logger.

It is used to send the logs to TcLogCore. Typically, it is instantiated once in each FUNCTION_BLOCK or PROGRAM where logging is done. The same instance can then be used for all logging within that POU.

TcLog implements a string builder that facilitates the compilation of the log message without the need for external data type conversions or multiple chained CONCAT calls. See the method section for more information.

The last method to call after the log message has been built is one of ´[Debug|Information|Warning|Error|Fatal]. This sets the log level of the message and sends it off to the log message queue of TcLogCore` where it will be processed according to its configuration.

Methods

AppendAny

Appends any given data to the log string. The type of the provided data has to be one of the standard data types. This method can be chained.

Declaration
METHOD AppendAny (
 data : ANY) : REFERENCE TO TcLog
Inputs
Name Type Description
data ANY data to be appended to log string.

AppendString

Appends another string to the log message. This method can be chained.

Declaration
METHOD AppendString (
 data : Tc2_System.T_MaxString) : REFERENCE TO TcLog
Inputs
Name Type Description
data Tc2_System.T_MaxString data to be appended to log string.

AppendVariable

Appends information about the given variable to the log string. This method can be chained. Example:

VAR
  Logger: TcLog;
   myInt : INT := 10;
  myVarInfo : __SYSTEM.VAR_INFO := __VARINFO(myInt);
END_VAR
Logger.AppendVariable(myVarInfo, myInt);
Declaration
METHOD AppendVariable (
 varInfo : __SYSTEM.VAR_INFO,
 value : ANY) : REFERENCE TO TcLog
Inputs
Name Type Description
varInfo __SYSTEM.VAR_INFO VAR_INFO of variable to be appended to log string.
value ANY Value of variable to be appended to log string.

Debug

Logs the log string in DEBUG level.

Declaration
METHOD Debug (
 message : Tc2_System.T_MaxString) : BOOL
Inputs
Name Type Description
message Tc2_System.T_MaxString Message to be appended to log string.

Error

Logs the log string in ERROR level.

Declaration
METHOD Error (
 message : Tc2_System.T_MaxString) : BOOL
Inputs
Name Type Description
message Tc2_System.T_MaxString Message to be appended to log string.

Fatal

Logs the log string in FATAL level.

Declaration
METHOD Fatal (
 message : Tc2_System.T_MaxString) : BOOL
Inputs
Name Type Description
message Tc2_System.T_MaxString Message to be appended to log string.

Information

Logs the log string in INFORMATION level.

Declaration
METHOD Information (
 message : Tc2_System.T_MaxString) : BOOL
Inputs
Name Type Description
message Tc2_System.T_MaxString Message to be appended to log string.

Init

Initializes the reference to the core logger. Should only be called once from the core logger directly.

Declaration
METHOD PUBLIC Init (
 ref2Core : ILogCore) : BOOL
Inputs
Name Type Description
ref2Core TcLogLib.ILogCore Reference to TcLoggerCore instance.

InitializeLogData

Declaration
METHOD PRIVATE InitializeLogData () : BOOL

OnCondition

Conditional execution of the log command. Only executes logging when Cond = TRUE.

Declaration
METHOD OnCondition (
 cond : BOOL) : REFERENCE TO TcLog
Inputs
Name Type Description
cond BOOL Logs data only if this condition evaluates to TRUE.

SetLogger

Initializes the reference to the core logger. This enables you to use several loggers with different configurations in one project.

Declaration
METHOD SetLogger (
 ref2Core : ILogCore) : BOOL
Inputs
Name Type Description
ref2Core TcLogLib.ILogCore Reference to Core Logger

ToAdsLog

Logs directly to ADS log, ignoring the settings of the base logger.

Declaration
METHOD ToAdsLog (
 logLevel : LogLevels) : BOOL
Inputs
Name Type Description
logLevel TcLogLib.LogLevels Log level in which message should be logged to ADS.

ToCustomFormat

Saves custom formatted log string. No addtitional information will be added, no formatting will be applied.

Declaration
METHOD ToCustomFormat (
 message : Tc2_System.T_MaxString) : BOOL
Inputs
Name Type Description
message Tc2_System.T_MaxString Message to be appended to log string.

Warning

Logs the log string in WARNING level.

Declaration
METHOD Warning (
 message : Tc2_System.T_MaxString) : BOOL
Inputs
Name Type Description
message Tc2_System.T_MaxString Message to be appended to log string.
In this article
Back to top Documentation powered by zkdoc