ibm-information-center/dist/eclipse/plugins/i5OS.ic.apis_5.4.0.1/p0zlog.htm

296 lines
9.2 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Copyright" content="Copyright (c) 2006 by IBM Corporation">
<title>Qp0zLprintf()--Print Formatted Job Log Data</title>
<!-- Begin Header Records ========================================== -->
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<!-- Change History: -->
<!-- YYMMDD USERID Change description -->
<!-- Direct1 SCRIPT J converted by B2H R4.1 (346) (CMS) by V2KEA304 -->
<!-- at RCHVMW2 on 17 Feb 1999 at 11:05:09 -->
<!-- Edited by Kersten Feb 02 -->
<!-- This file has undergone error code cleanup on 04/30/02 by JET -->
<!-- End Header Records -->
<link rel="stylesheet" type="text/css" href="../rzahg/ic.css">
</head>
<body>
<!-- Java sync-link -->
<script type="text/javascript" language="Javascript" src="../rzahg/synch.js">
</script>
<a name="Top_Of_Page"></a>
<h2>Qp0zLprintf()--Print Formatted Job Log Data</h2>
<div class="box" style="width: 60%;">
<br>
&nbsp;&nbsp;Syntax<br>
<pre>
#include &lt;qp0ztrc.h&gt;
int Qp0zLprintf(char <em>*format-string</em>, ...);
</pre>
<br>
&nbsp;&nbsp;Service Program Name: QP0ZCPA<br>
<!-- iddvc RMBR -->
<br>
&nbsp;&nbsp;Default Public Authority: *USE<br>
<!-- iddvc RMBR -->
<br>
&nbsp;&nbsp;Threadsafe: Yes<br>
<!-- iddvc RMBR -->
<br>
</div>
<p>The <strong>Qp0zLprintf()</strong> function prints user data specified by
<em>format-string</em> as an information message type to the job log.</p>
<p>If a second parameter, <em>argument-list</em>, is provided, <strong>
Qp0zLprintf()</strong> converts each entry in the <em>argument-list</em> and
writes the entry to the job log according to the corresponding format
specification in <em>format-string</em>. If there are more entries in <em>
argument-list</em> than format specifications in <em>format-string</em>, the
extra <em>argument-list</em> entries are evaluated and then ignored. If there
are less entries in <em>argument-list</em> than format specifications in
<em>format-string</em>, the job log output for those entries is undefined,
and the <strong>Qp0zLprintf()</strong> function may return an error.</p>
<p>The data printed by <strong>Qp0zLprintf()</strong> is buffered one line at a
time, and a new message in the job log is forced every 512 characters if a new
line (\n) is not detected in the data before that time. The buffer used by
<strong>Qp0zLprintf()</strong> is not physically written when the application
ends. To ensure messages are written to the job log, always use a new line (\n)
at the end of each <em>format-string</em>.</p>
<p>An application should not use the tracing function in performance critical
code. These functions are intended for debugging exceptions or error
conditions.</p>
<br>
<h3>Parameters</h3>
<dl>
<dt><strong><em>format-string</em></strong></dt>
<dd>(Input) The format string representing the format of the data to be
printed. See the <strong>printf()</strong> function in <a href=
"../books/sc415607.pdf" target="_blank">ILE C/C++ Run-Time
Library Functions</a><img src="wbpdf.gif" alt="Link to PDF">for a description
of valid format strings.<br>
<br>
</dd>
<dt><strong><em>... (argument-list)</em></strong></dt>
<dd>(Input) An optional list of arguments that contain entries to be formatted
and printed to the job log.</dd>
</dl>
<br>
<h3>Authorities</h3>
<p>None.</p>
<br>
<h3>Return Value</h3>
<table cellpadding="5">
<!-- cols="10 90" -->
<tr>
<td align="left" valign="top"><em>value</em></td>
<td align="left" valign="top"><strong>Qp0zLprintf()</strong> was successful.
The value returned is the number of characters successfully printed.</td>
</tr>
<tr>
<td align="left" valign="top"><em>-1</em></td>
<td align="left" valign="top"><strong>Qp0zLprintf()</strong> was not
successful. The <em>errno</em> variable is set to indicate the error.</td>
</tr>
</table>
<br>
<br>
<h3>Error Conditions</h3>
<p>If <strong>Qp0zLprintf()</strong> is not successful, <em>errno</em>
usually indicates one of the following errors. Under some conditions, <em>
errno</em> could indicate an error other than that listed here.</p>
<dl>
<dt><em>[EINVAL]</em></dt>
<dd>
<p>The value specified for the argument is not correct.</p>
<p>A function was passed incorrect argument values, or an operation was
attempted on an object and the operation specified is not supported for that
type of object.</p>
<p>An argument value is not valid, out of range, or NULL. An invalid <em>
format-string</em> or <em>argument-list</em> was specified.</p>
</dd>
<dt><em>[EFAULT]</em></dt>
<dd>
<p>The address used for an argument is not correct.</p>
<p>In attempting to use an argument in a call, the system detected an address
that is not valid.</p>
<p>While attempting to access a parameter passed to this function, the system
detected an address that is not valid.</p>
</dd>
</dl>
<br>
<h3><a name="USAGE_NOTES">Usage Notes</a></h3>
<p>None.</p>
<br>
<h3>Related Information</h3>
<ul>
<li><a href="p0zdmp.htm">Qp0zDump()</a>--Dump Formatted Storage Trace Data<br>
<br>
</li>
<li><a href="p0zdmps.htm">Qp0zDumpStack()</a>--Dump Formatted Stack Trace
Data<br>
<br>
</li>
<li><a href="p0zdmpt.htm">Qp0zDumpTargetStack()</a>--Dump Formatted Stack Trace
Data of the Target Thread<br>
<br>
</li>
<li><a href="p0zprnt.htm">Qp0zUprintf()</a>--Print Formatted User Trace
Data</li>
</ul>
<br>
<h3>Example</h3>
<p>See <a href="../apiref/aboutapis.htm#codedisclaimer">Code disclaimer information</a>
for information pertaining to code examples.</p>
<p>The following example uses <strong>Qp0zLprintf()</strong> to produce output
in the job log.</p>
<pre>
#define _MULTI_THREADED
#include &lt;pthread.h&gt;
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;unistd.h&gt;
#include &lt;qp0ztrc.h&gt;
#define THREADDATAMAX 128
void *theThread(void *parm)
{
char *myData = parm;
Qp0zLprintf("%.8x %.8x: Entered the %s thread\n",
pthread_getthreadid_np(), myData);
free(myData);
return NULL;
}
int main(int argc, char **argv)
{
pthread_t thread, thread2;
int rc=0;
char *threadData;
printf("Create two threads\n");
Qp0zUprintf("Tracing creation of two threads\n");
threadData = (char *)malloc(THREADDATAMAX);
sprintf(threadData, "50%% Cotton, 50%% Polyester");
rc = pthread_create(&amp;thread, NULL, theThread, threadData);
if (rc) {
printf("Failed to create a %s thread\n", threadData);
exit(EXIT_FAILURE);
}
threadData = (char *)malloc(THREADDATAMAX);
sprintf(threadData, "Lacquered Camel Hair");
rc = pthread_create(&amp;thread2, NULL, theThread, threadData);
if (rc) {
printf("Failed to create a %s thread\n", threadData);
exit(EXIT_FAILURE);
}
printf("Wait for threads to complete\n");
rc = pthread_join(thread, NULL);
if (rc) { printf("Failed pthread_join() 1\n"); exit(EXIT_FAILURE); }
rc = pthread_join(thread2, NULL);
if (rc) { printf("Failed pthread_join() 2\n"); exit(EXIT_FAILURE); }
return 0;
}
</pre>
<br>
<h3>Job Log Output:</h3>
<p>The following two job log messages where generated by the example shown
above. The output was retrieved from the spooled file created when the job ran
to completion and when the job log was retained. The informational messages
contain the contents of the <strong>Qp0zLprintf()</strong> function calls.</p>
<br>
br>
<pre>
*NONE Information 01/05/98 16:55:05 QP0ZCPA QSYS *STMT QP0ZCPA QSYS *STMT
From module . . . . . . . . : QP0ZUDBG
From procedure . . . . . . : Qp0zVLprintf
Statement . . . . . . . . . : 296
To module . . . . . . . . . : QP0ZUDBG
To procedure . . . . . . . : Qp0zVLprintf
Statement . . . . . . . . . : 296
Thread . . . . : 0000001A
Message . . . . : 00000000 0000001a: Entered the 50% Cotton, 50% Polyester thread
*NONE Information 01/05/98 16:55:05 QP0ZCPA QSYS *STMT QP0ZCPA QSYS *STMT
From module . . . . . . . . : QP0ZUDBG
From procedure . . . . . . : Qp0zVLprintf
Statement . . . . . . . . . : 296
To module . . . . . . . . . : QP0ZUDBG
To procedure . . . . . . . : Qp0zVLprintf
Statement . . . . . . . . . : 296
Thread . . . . : 0000001B
Message . . . . : 00000000 0000001b: Entered the Lacquered Camel Hair thread
</pre>
<br>
<br>
<hr>
API introduced: V4R3
<hr>
<center>
<table cellpadding="2" cellspacing="2">
<tr align="center">
<td valign="middle" align="center"><a href="#Top_Of_Page">Top</a> | <a href=
"unix.htm">UNIX-Type APIs</a> | <a href="aplist.htm">APIs by category</a></td>
</tr>
</table>
</center>
</body>
</html>