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

TcLog

Namespace
TcLogLib
Implements
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.

FUNCTION_BLOCK TcLog IMPLEMENTS TcLogLib.ILog

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.

METHOD AppendAny (
 data : ANY) : REFERENCE TO TcLog

Inputs

data ANY

data to be appended to log string.

Returns

REFERENCE TO TcLog

AppendString

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

METHOD AppendString (
 data : Tc2_System.T_MaxString) : REFERENCE TO TcLog

Inputs

data Tc2_System.T_MaxString

data to be appended to log string.

Returns

REFERENCE TO TcLog

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);
METHOD AppendVariable (
 varInfo : __SYSTEM.VAR_INFO,
 value : ANY) : REFERENCE TO TcLog

Inputs

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.

Returns

REFERENCE TO TcLog

Debug

Logs the log string in DEBUG level.

METHOD Debug (
 message : Tc2_System.T_MaxString) : BOOL

Inputs

message Tc2_System.T_MaxString

Message to be appended to log string.

Returns

BOOL

Error

Logs the log string in ERROR level.

METHOD Error (
 message : Tc2_System.T_MaxString) : BOOL

Inputs

message Tc2_System.T_MaxString

Message to be appended to log string.

Returns

BOOL

Fatal

Logs the log string in FATAL level.

METHOD Fatal (
 message : Tc2_System.T_MaxString) : BOOL

Inputs

message Tc2_System.T_MaxString

Message to be appended to log string.

Returns

BOOL

Information

Logs the log string in INFORMATION level.

METHOD Information (
 message : Tc2_System.T_MaxString) : BOOL

Inputs

message Tc2_System.T_MaxString

Message to be appended to log string.

Returns

BOOL

Init

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

METHOD PUBLIC Init (
 ref2Core : ILogCore) : BOOL

Inputs

ref2Core ILogCore

Reference to TcLoggerCore instance.

Returns

BOOL

InitializeLogData

METHOD PRIVATE InitializeLogData () : BOOL

Returns

BOOL

OnCondition

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

METHOD OnCondition (
 cond : BOOL) : REFERENCE TO TcLog

Inputs

cond BOOL

Logs data only if this condition evaluates to TRUE.

Returns

REFERENCE TO TcLog

SetLogger

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

METHOD SetLogger (
 ref2Core : ILogCore) : BOOL

Inputs

ref2Core ILogCore

Reference to Core Logger

Returns

BOOL

ToAdsLog

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

METHOD ToAdsLog (
 logLevel : LogLevels) : BOOL

Inputs

logLevel LogLevels

Log level in which message should be logged to ADS.

Returns

BOOL

ToCustomFormat

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

METHOD ToCustomFormat (
 message : Tc2_System.T_MaxString) : BOOL

Inputs

message Tc2_System.T_MaxString

Message to be appended to log string.

Returns

BOOL

Warning

Logs the log string in WARNING level.

METHOD Warning (
 message : Tc2_System.T_MaxString) : BOOL

Inputs

message Tc2_System.T_MaxString

Message to be appended to log string.

Returns

BOOL
  • Edit this page
In this article
Back to top Documentation powered by zkdoc