Sun Java System Directory Server Enterprise Edition 6.1 Developer's Guide

slapi_log_error_ex()

Write an error message to the server error log.

Syntax

#include "slapi-plugin.h"
int slapi_log_error_ex(long errorId,
    long msgId, int connId, int opId, char const * subsystem,
    char const * humanReadableMsg, char const * fmt, /* args */ ...);

Parameters

This function takes the following parameters:

errorId

Unique identifier you provide for this error message

msgId

Identifier for the current message obtained using SLAPI_OPERATION_MSGID

connId

Identifier for the current connection obtained using SLAPI_CONN_ID

opId

Identifier for the current operation obtained using SLAPI_OPERATION_ID

subsystem

String indicating the context in which the warning arose such as the name of the plug-in function logging the message

humanReadableMsg

String message identifying this warning

fmt

Format specification in the style of printf()

args

Arguments for the format specification in fmt

Description

This function writes the specified error message to the server error log in synchronous fashion. This function does not return until the log message has been flushed to disk, thus blocking the server for the duration of the write operation. By default, the error log is $INSTANCE_PATH/logs/errors.

Unlike slapi_log_info_ex(), this function cannot be turned off.

Error messages typically concern fatal errors. For warnings, use slapi_log_warning_ex(). For informational log messages, use slapi_log_info_ex().

Example

Example 16–2 shows a call to slapi_log_error_ex().


Example 16–2 Logging an Error

#include "slapi-plugin.h"
#include "example-com-error-ids.h" /* example.com unique
                                      error IDs file       */
int
foobar(Slapi_PBlock * pb)
{
    char * error_cause;
    int    apocalypse = 1;         /* Expect the worst.    */

    /* ... */

    if (apocalypse) {              /* Server to crash soon */
        slapi_log_error_ex(
            EXCOM_SERVER_MORIBUND, /* Unique error ID      */
            SLAPI_LOG_NO_MSGID,
            SLAPI_LOG_NO_CONNID,
            SLAPI_LOG_NO_OPID,
            "example.com: foobar in baz plug-in",
            "cannot write to file system: %s\n",
            error_cause
        );
        return -1;
    }
    return 0;
}

Returns

This function returns 0 if successful. Otherwise, it returns -1.

See Also

slapi_log_info_ex()

slapi_log_warning_ex()