Open System Services Programmer's Guide
Example 55 Calling syslog() With Formatting Codes
fahr = 50;
syslog( LOG_DEBUG
, "%4d Fahrenheit -- %6.1f Centigrade "
, fahr
, (5.0/9.0)*(fahr - 32 ) );
This call produces the following message:
USER DEBUG : 50 Fahrenheit -- 10.0 Centigrade
You can use the %m formatting code to include the current error number. Example 56 shows a code
fragment with a call to syslog() using %m.
Example 56 Calling syslog() With the %m Formatting Code
len = read( master_fd , buf, MAX_READ_SIZE );
if ( len < 0 )
{
syslog( LOG_DEBUG, "READ Error %m on Master File" );
}
This call produces a message such as the following if there is an error:
USER DEBUG : READ Error 4209 on Master File
where 4209 is an OSS file-system error number. You can obtain the related message string with
the perror() or strerror() functions.
Example 57 (page 242) provides a complete program showing the use of the system logging
functions in an OSS program.
How to Log Information With the OSS API 241