11.31.3 Writing to the Event Log
To write a message to the event log, you must perform the following steps:
- Assign the error message you wish to write to the log to a
variable of type
char *
and use the variable name as the argument to the call. - Specify the literal text of the message within double quotes, as the argument to the
userlog(3c)
call, as shown in the following example:. . /* Open the database to be accessed by the transactions.*/ if(tpopen() == -1) { userlog("tpsvrinit: Cannot open database %s, tpstrerror(tperrno)"); return(-1); } . . .
In this example, the message is sent to the central event log if tpopen(3c)
returns -1
.
The userlog(3c)
signature is similar to that of the
UNIX System printf
(3S) function. The format portion of
both functions can contain literal strings and/or conversion
specifications for a variable number of arguments.
Parent topic: Central Event Log