Contained WithinFind More DocumentationFeatured Support Resources | Descargar este libro en PDF (1531 KB)
Chapter 5 Logging Data Types and FunctionsSun OpenSSO Enterprise contains public data types and functions you can use for logging on the local system or on Sun OpenSSO Enterprise. Reference summaries include a short description, syntax, parameters and returns. The code is contained in the <am_log.h> header file. The sample source am_log_test.c demonstrates the basic usage of the logging API to record information such as user activity, traffic patterns and authorization violations. This chapter contains the following sections: The Logging API for CThe logging API is designed to allow C applications to produce messages of interest and write them to the OpenSSO Enterprise logs. When some type of event occurs in an external application, the application code first determines if the logging module (a file created for messages usually relevant to a specific function or feature) to which the event is relevant has a level high enough to log the event. (A level specifies importance and defines the amount of detail that will be logged.) If the determination is affirmative, a log message is generated and a log record created in the relevant logging module. Information in the log record can be updated as necessary. The following notes regard the logging API for C functionality:
Logging Data TypesThe logging data types defined in <am_log.h> are: am_log_record_tRepresents the information and message values to be recorded. Note – See Chapter 15, Recording Events with the Logging Service, in Sun OpenSSO Enterprise 8.0 Technical Overview for information regarding events that are logged and the log fields to which they are written. Syntax#include "am_log.h" typedef struct am_log_record *am_log_record_t; Membersam_log_record is an opaque structure with no accessible members. am_log_module_id_tRepresents the identifier for a logging module. Note – See am_log_add_module() for information on logging modules. Syntax#include "am_log.h" typedef unsigned int am_log_module_id_t; Membersam_log_module_id_t has no members. Logging FunctionsThe logging functions defined in <am_log.h> are: am_log_add_module()Adds a new logging file (for a specific function or feature) to the OpenSSO Enterprise Logging Service. DetailsThe currently used module file names are:
Syntax#include "am_log.h"
AM_EXPORT am_status_t
am_log_add_module(const char *name,
am_log_module_id_t *id_ptr);
ParametersThis function takes the following parameters:
ReturnsThis function returns one of the following values of the am_status_t enumeration (defined in the <am_types.h> header file): Note – If a module of the same name already exists, the module identifier of the existing module is returned.
am_log_flush_remote_log()Flushes all the log records in the OpenSSO Enterprise log buffer. Syntax#include "am_log.h" AM_EXPORT am_status_t am_log_flush_remote_log(); ParametersThis function takes no parameters: ReturnsThis function returns one of the following values of the am_status_t enumeration (defined in the <am_types.h> header file):
am_log_init()Initializes the Logging Service. Detailsam_log_init() writes events to the logs on the OpenSSO Enterprise server. Syntax#include "am_log.h" AM_EXPORT am_status_t am_log_init(const am_properties_t log_init_params); ParametersThis function takes the following parameter:
ReturnsThis function returns one of the following values of the am_status_t enumeration (defined in the <am_types.h> header file):
am_log_is_level_enabled()Checks whether an event at the specified level intended for the specified logging module should generate a logging message. DetailsIf the level of the event is not equal to or higher than the level of the logging module, a logging message will not be generated. Syntax#include "am_log.h"
AM_EXPORT boolean_t
am_log_is_level_enabled(am_log_module_id_t moduleID,
am_log_level_t level);
ParametersThis function takes the following parameters:
ReturnsThis function returns one of the following values of the boolean_t enumeration (defined in the standard <types.h> header file): Note – The code used is dependent on the server operating system.
am_log_log()Produces a logging message from the specified event string. DetailsWhen using am_log_log(), consider the following:
Syntax#include "am_log.h"
AM_EXPORT boolean_t
am_log_log(am_log_module_id_t moduleID,
am_log_level_t level,
const char *format, ...);
ParametersThis function takes the following parameters:
ReturnsThis function returns one of the values of the boolean_t enumeration (defined in the standard <types.h> header file): Note – The code used is dependent on the server operating system.
am_log_log_record()Writes the given log record to the specified logging module. Syntax#include "am_log.h"
AM_EXPORT am_status_t
am_log_log_record(am_log_record_t record,
const char *log_name,
const char *logged_by_token_id);
ParametersThis function takes the following parameters:
ReturnsThis function returns one of the following values of the am_status_t enumeration (defined in the <am_types.h> header file):
am_log_record_add_loginfo()Updates a log record with additional information. Syntax#include "am_log.h"
AM_EXPORT am_status_t
am_log_record_add_loginfo(am_log_record_t record,
const char *key,
const char *value);
ParametersThis function takes the following parameters:
ReturnsThis function returns one of the values of the am_status_t enumeration (defined in the <am_types.h> header file). am_log_record_create()Instantiates a log record, initializing it with a message and the message's corresponding level. Syntax#include "am_log.h"
AM_EXPORT am_status_t
am_log_record_create(am_log_record_t *record_ptr,
am_log_record_log_level_t log_level,
const char *message);
ParametersThis function takes the following parameters:
ReturnsThis function returns one of the values of the am_status_t enumeration (defined in the <am_types.h> header file). am_log_record_destroy()Destroys the specified log record. Syntax#include "am_log.h" AM_EXPORT am_status_t am_log_record_destroy(am_log_record_t record); ParametersThis function takes the following parameter:
ReturnsThis function returns one of the values of the am_status_t enumeration (defined in the <am_types.h> header file). am_log_record_populate()Updates a log record with the user’s session identifier (also known as an SSOTokenID). DetailsSee Single Sign-on Token Handles for more information. Syntax#include "am_log.h"
AM_EXPORT am_status_t
am_log_record_populate(am_log_record_t record,
const char *user_token_id);
ParametersThis function takes the following parameters:
ReturnsThis function returns one of the values of the am_status_t enumeration (defined in the <am_types.h> header file). am_log_record_set_log_level()Sets the level for the specified log record. Syntax#include "am_log.h"
AM_EXPORT am_status_t
am_log_record_set_log_level(am_log_record_t record,
am_log_record_log_level_t log_level);
ParametersThis function takes the following parameters:
ReturnsThis function returns one of the values of the am_status_t enumeration (defined in the <am_types.h> header file). am_log_record_set_log_message()Sets the log message to the log record before localization and formatting. Syntax#include "am_log.h"
AM_EXPORT am_status_t
am_log_record_set_log_message(am_log_record_t record,
const char *message);
ParametersThis function takes the following parameters:
ReturnsThis function returns one of the values of the am_status_t enumeration (defined in the <am_types.h> header file). am_log_record_set_loginfo_props()Updates the specified log record with additional information. Detailslog_info is expected to have the information formatted as key/value pairs in a properties map. Delete the am_properties_t pointer only when finished with the SDK. See am_properties_t for more information. Syntax#include "am_log.h"
AM_EXPORT am_status_t
am_log_record_set_loginfo_props(am_log_record_t record,
am_properties_t log_info);
ParametersThis function takes the following parameters:
ReturnsThis function returns one of the values of the am_status_t enumeration (defined in the <am_types.h> header file). am_log_set_levels_from_string()Sets the level for the logging modules listed in a specified string. DetailsThe format of the string must be:
Optional spaces may occur before and after any commas. The comma, brackets and asterisk in the second term signifies that it can occur 0 or more times. Syntax#include "am_log.h" AM_EXPORT am_status_t am_log_set_levels_from_string(const char *module_level_string); ParametersThis function takes the following parameter:
ReturnsThis function returns one of the following values of the am_status_t enumeration (defined in the <am_types.h> header file):
am_log_set_log_file()Sets the name of the file to use for logging. Syntax#include "am_log.h" AM_EXPORT am_status_t am_log_set_log_file(const char *name); ParametersThis function takes the following parameter:
ReturnsThis function returns one of the following values of the am_status_t enumeration (defined in the <am_types.h> header file):
am_log_set_module_level()Sets the level for the specified logging module. Syntax#include "am_log.h"
AM_EXPORT am_log_level_t
am_log_set_module_level(am_log_module_id_t moduleID,
am_log_level_t level);
ParametersThis function takes the following parameters:
ReturnsThis function returns am_log_level_t with one of the following values:
am_log_set_remote_info()Initializes the remote log service. DetailsThis must be called before am_log_log() with AM_LOG_REMOTE_MODULE as the log module. Initialization is done only once. Subsequently, only remote logging calls are done. Syntax#include "am_log.h"
AM_EXPORT am_status_t
am_log_set_remote_info(const char *rem_log_url,
const char *sso_token_id,
const char *rem_log_name,
const am_properties_t log_props);
ParametersThis function takes the following parameters:
ReturnsThis function returns one of the values of the am_status_t enumeration (defined in the <am_types.h> header file). am_log_vlog()Logs a message for the specified module at the given level. DetailsWhen using am_log_vlog(), consider the following:
Syntax#include "am_log.h"
AM_EXPORT boolean_t
am_log_vlog(am_log_module_id_t moduleID,
am_log_level_t level,
const char *format,
va_list args);
ParametersThis function takes the following parameters:
ReturnsThis function returns one of the values of the boolean_t enumeration (defined in the standard <types.h> header file): Note – The code used is dependent on the server operating system. See <am_types.h> for more details.
|
|