# Logging
[Functions]

## Detailed Description

These functions can be used to receive and emit log messages related to a particular plug-in context.

They can be used by the main program or by a plug-in runtime.

## Functions

cp_status_t | cp_register_logger (cp_context_t *ctx, cp_logger_func_t logger, void *user_data, cp_log_severity_t min_severity)
| Registers a logger with a plug-in context or updates the settings of a registered logger.
void | cp_unregister_logger (cp_context_t *ctx, cp_logger_func_t logger)
| Removes a logger registration.
void | cp_log (cp_context_t *ctx, cp_log_severity_t severity, const char *msg)
| Emits a new log message.
int | cp_is_logged (cp_context_t *ctx, cp_log_severity_t severity)
| Returns whether a message of the specified severity would get logged.

## Function Documentation

cp_status_t cp_register_logger | ( | cp_context_t * | ctx,
|  | cp_logger_func_t | logger,
|  | void * | user_data,
|  | cp_log_severity_t | min_severity |
| ) |  |  |

Registers a logger with a plug-in context or updates the settings of a registered logger.

The logger will receive selected log messages. If the specified logger is not yet known, a new logger registration is made, otherwise the settings for the existing logger are updated. The logger can be unregistered using cp_unregister_logger and it is automatically unregistered when the registering plug-in is stopped or when the context is destroyed.

Parameters:

  | ctx | the plug-in context to log
  | logger | the logger function to be called
  | user_data | the user data pointer passed to the logger
  | min_severity | the minimum severity of messages passed to logger

Returns:
  CP_OK (zero) on success or CP_ERR_RESOURCE if insufficient memory

void cp_unregister_logger | ( | cp_context_t * | ctx,
|  | cp_logger_func_t | logger |
| ) |  |  |

Removes a logger registration.

Parameters:

  | ctx | the plug-in context
  | logger | the logger function to be unregistered

void cp_log | ( | cp_context_t * | ctx,
|  | cp_log_severity_t | severity,
|  | const char * | msg |
| ) |  |  |

Emits a new log message.

Parameters:

  | ctx | the plug-in context
  | severity | the severity of the event
  | msg | the log message (possibly localized)

int cp_is_logged | ( | cp_context_t * | ctx,
|  | cp_log_severity_t | severity |
| ) |  |  |

Returns whether a message of the specified severity would get logged.

Parameters:

  | ctx | the plug-in context
  | severity | the target logging severity

Returns:
  whether a message of the specified severity would get logged

Generated on Fri Apr 6 15:40:55 2007 for C-Pluff C API by 1.5.1