Write an error message to the server error log.
#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 */ ...);
This function takes the following parameters:
Unique identifier you provide for this error message
Identifier for the current message obtained using SLAPI_OPERATION_MSGID
Identifier for the current connection obtained using SLAPI_CONN_ID
Identifier for the current operation obtained using SLAPI_OPERATION_ID
String indicating the context in which the warning arose such as the name of the plug-in function logging the message
String message identifying this warning
Format specification in the style of printf()
Arguments for the format specification in fmt
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 16–2 shows a call to slapi_log_error_ex().
#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; }
This function returns 0 if successful. Otherwise, it returns -1.