Page 1 of 1

Writing to the Log file from a transformer in a Parallel Job

Posted: Thu Apr 03, 2008 4:17 am
by CharlesNagy
Hi,

I am trying to write a message to the logfile from a parallel transformer if a certain condition is not met... eg:

If condition then pass Data else log message

I presume I will have to write a C++ routine, but I dont know what command to issue to accomplish this. I have tried a simple cout, but that doesn't work.

Any ideas anyone?

Posted: Thu Apr 03, 2008 4:30 am
by ray.wurlod
It will slow the job down immensely but it can be done. It's probably best to call your routine from a stage variable, so that you can discard the result. Write your routine using the C-language DataStage API; you probably need DSLogInfo() or DSLogWarn() somewhere within the code.
See Parallel Job Advanced Developer's Guide around page 7-6.

Posted: Thu Apr 03, 2008 7:46 am
by CharlesNagy
Thanks Ray,

Will check it out...
ray.wurlod wrote:It will slow the job down immensely but it can be done. It's probably best to call your routine from a stage variable, so that you can discard the result. Write your routine using the C-language DataStage API; you probably need DSLogInfo() or DSLogWarn() somewhere within the code.
See Parallel Job Advanced Developer's Guide around page 7-6.

Function to write to the Log File

Posted: Thu Apr 03, 2008 10:44 am
by CharlesNagy
After closer inspection, cout actually works.

I wrote the following function which I call from a transformer, and it does indeed write to the log file.

Code: Select all

void writeLog(char *logMsg)
{
     cout << logMsg << endl;

     return ;
}

It appears in the log with an APT_CombinedOperatorController event...

Posted: Thu Apr 03, 2008 5:27 pm
by ray.wurlod
That's only because you have operator combination enabled. What you have described as the "event" is actually the Orchestrate operator that is posting the message. With operator combination disabled the message would be posted by a transform operator (that, curiously, would have the same name as your Transformer stage - magic!).