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:
|
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:
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);