Show Table of Contents
Chapter 5. Frontend API Functions
The Red Hat Directory Server (Directory Server) provides some general-purpose, frontend API functions that allow you to work with the entries in the Directory Server. This chapter explains how to use the frontend API functions to accomplish various tasks; you can call these functions in your plug-in to interact with the client (for example, to send results or result codes), log messages, and work with entries, attributes, and filters. While all of the functions described here must be used in conjunction with other API functions, understanding how these functions work will help you understand how to program other plug-in API functions.
The frontend functions are declared in the
slapi-plugin.h header file.
5.1. Logging Messages
To write an error message to the error log, call the slapi_log_error() function. For example, the following function call writes a message in the error log:
slapi_log_error( SLAPI_LOG_PLUGIN, "searchdn_preop_search", "*** PREOPERATION SEARCH PLUGIN ***\n");
This call will create the following message in the error log:
[01/Oct/2015:02:24:18.577543334 -0700] searchdn_preop_search *** PREOPERATION SEARCH PLUGIN ***
Make sure that the Directory Server is configured to log messages that have the severity that you specify (for example,
SLAPI_LOG_PLUGIN). For more information, see Section 3.5, “Setting the Log Level of the Server”. The slapi_log_error() function allows additional parameters to be added to the function and to format the output, similar to the standard printf() function. This provides a way to add custom parameters and data to the log output.
Some debugging output is expensive to calculate, so check if a certain log level is set before doing additional processing. The slapi_is_loglevel_set() function can determine if the log level is set. For example:
if (slapi_loglevel_is_set(SLAPI_LOG_PLUGIN)) {
do some expensive processing for debugging purposes....
slapi_log_error(SLAPI_LOG_PLUGIN, .my plugin., ... some data...);
}
Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.