Write a message to the Open Server log file.
CS_RETCODE srv_log(ssp, datestamp, msgp, msglen)
SRV_SERVER *ssp; CS_BOOL datestamp; CS_CHAR *msgp; CS_INT msglen;
The handle to the Open Server. This argument is optional. It is only present for backward compatibility.
If datestamp is CS_TRUE, the current date and time is added to the beginning of the log message. If datestamp is CS_FALSE, the log message is not timestamped.
A pointer to the actual text of the message.
The length in bytes of msg. If the string in *msgp is null terminated, msglen can be CS_NULLTERM.
Returns |
To indicate |
---|---|
CS_SUCCEED |
The routine completed successfully. |
CS_FAIL |
The routine failed. |
#include <ospublic.h>
#include <string.h>
/*
** Local Prototype.
*/
CS_RETCODE ex_srv_log PROTOTYPE((
SRV_SERVER *ssp,
CS_CHAR *msg_txt
));
/*
** EX_SRV_LOG
**
** Example routine to log a message.
**
** Arguments:
**
** ssp A pointer to the Open Server state information
** control structure.
** msg_txt Text of message to log.
** Returns
**
** CS_SUCCEED Thread was created.
** CS_FAIL An error was detected.
**
*/
CS_RETCODE ex_srv_log(ssp, msg_txt)
SRV_SERVER *ssp;
CS_CHAR *msg_txt;
{
CS_RETCODE lret;
CS_INT msg_len;
/* Check arguments. */
if(ssp == (SRV_SERVER *)0)
return(CS_FAIL);
if(msg_txt == (CS_CHAR *)NULL)
return(CS_FAIL);
msg_len=strlen(msg_txt);
/*
** Log the message - We use CS_TRUE as the second argument
** to force the date and time to be
** added to the beginning of the logged
** message. If you do not want a
** datestamp then use CS_FALSE.
*/
lret = srv_log(ssp,CS_TRUE,msg_txt,msg_len);
return(lret);
}
srv_log writes messages to the Open Server log file. The default name of the log file is srv.log. The name can be set with srv_props.
Messages are always appended to the log file.
The name of the log file can be accessed with the srv_props routine.
The newline character is not added to the text in *msgp.
The log file is truncated based on the SRV_TRUNCATELOG property set through srv_props.
If the message length exceeds SRV_MAXMSG, Open Server truncates the message. This holds true whether or not the message is null terminated.
If srv_init has not completed, the message goes to the boot window.