srv_log

Description

Write a message to the Open Server log file.

Syntax

CS_RETCODE srv_log(ssp, datestamp, msgp, msglen)
SRV_SERVER    *ssp;
CS_BOOL           datestamp;
CS_CHAR           *msgp;
CS_INT              msglen;

Parameters

ssp

The handle to the Open Server. This argument is optional. It is only present for backward compatibility.

datestamp

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.

msgp

A pointer to the actual text of the message.

msglen

The length in bytes of msg. If the string in *msgp is null terminated, msglen can be CS_NULLTERM.

Returns

Table 3-61: Return values (srv_log)

Returns

To indicate

CS_SUCCEED

The routine completed successfully.

CS_FAIL

The routine failed.

Examples

Example 1

#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);
}

Usage

See also

srv_props