17.00 - Write to Log Stream - Parallel Transporter

Teradata® Parallel Transporter Operator Programmer Guide

prodname
Parallel Transporter
vrm_release
17.00
created_date
June 2020
category
Programming Reference
featnum
B035-2435-220K

Purpose

Write to Log Stream is the service function that is used for submitting log messages.

Structure

#include <pxoper.h>
PXSTC_Code PX_LogWrite(PX_LogHandle  loghandle,
PXInt32  messagenumber,
PXInt32  destination,
PXInt32  messagecategory,
...);

where the following is true:

Parameter Function Specification
destination input Destination bit mask describing which destinations the message should go to. Any combination of LOG_DEST_CONS and LOG_DEST_LOG is valid. Multiple destinations are entered by or’ing the values (LOG_DEST_CONS | LOG_DEST_LOG).
loghandle input Handle to the log stream (returned from PX_LogInit())
messagecategory input Category of the message. The valid message categories are:
  • LOG_DEBUG
  • LOG_TRACE
  • LOG_INFO
  • LOG_WARNING
  • LOG_FATALERROR
  • LOG_USERERROR
messagenumber input Number of the message in the message catalog.

The message catalog is identified in the DEFINE OPERATOR statement in the Teradata PT script.

The message described by the message number, is used as a format string when accessed from the Log View Client.

... input Arguments to the message (1..*).
This variable list of parameters is the arguments that will go into the format string from the message catalog. Each argument is supplied with type and value. This is handled by a set of macros in the following way:
  • LOG_INT16(val) - Short integer values. For example, LOG_INT16(5) corresponds to supplying the short value 5.
  • LOG_INT32(val) - Long integer values. E.g. LOG_INT32(56) corresponds to supplying the long value 56.
  • LOG_INT64(val) - Long long values. E.g. LOG_INT64(578) corresponds to supplying the long value 578.
  • LOG_CHAR(val) - Character values. E.g. LOG_CHAR('g') corresponds to supplying the character 'g'.
  • LOG_STRING(val) - String values. E.g. LOG_STRING("mystring") corresponds to supplying the string "mystring".
  • LOG_FLOAT(val) - 32 bit floating point values. E.g. LOG_FLOAT(5.4) corresponds to supplying the floating point value 5.4.
  • LOG_DOUBLE(val) - 64 bit floating point values. E.g. LOG_DOUBLE(5.7) corresponds to supplying the double precision floating point value 5.7.

This list must always end with PXEOP (EndOfParameterList) as the last parameter. Failure to do so will make the program loop and eventually incur a memory fault.

Return Codes

The following Write to Log Stream function status codes are defined by the Teradata PT operator interface.

Status Code Signifies
PXSTC_Success The call succeeded.
PXSTC_LogCommunicationError An error occurred from socket communication with the Node Logger.
PXSTC_LogInsuffMemError A memory allocation failure.
PXSTC_InvalidDataType The type of some of the parameters is unknown to the Logger API.
PXSTC_NoMessageCatalog The requested message catalog is not present.
PXSTC_UnknownError Unknown error encountered when writing a log record.

Usage Notes

Consider the following when defining the Write to Log Stream function.

Topic Usage Notes
Status If the function status if PXSTC_Success, the message was successfully written to the message catalog by this function. See also Initiate Log Stream.

Example - Write to Log Stream

#include <pxoper.h>
PX_ErrorProc myerror;
PX_LogHandle loghandle;
PX_LogInit(oprhandle, "mycomponent", 75, NULL, myerror, &loghandle);
PX_LogWrite(loghandle, mymessagenumber,
  LOG_DEST_CONS | LOG_DEST_LOG,
  LOG_FATALERROR, ...);
PX_LogTerminate(loghandle);