Apama Documentation : Connecting Apama Applications to External Components : Working with IAF Plug-ins : C/C++ Plug-in Support APIs : Logging from plug-ins in C/C++
Logging from plug-ins in C/C++
This API provides a mechanism for recording status and error log messages from the IAF runtime and any plug-ins loaded within it. Plug-in developers are encouraged to make use of the logging API instead of custom logging solutions so that all the information may be logged together in the same standard format and log file(s) used by other plug-ins and the IAF runtime.
The logging API also allows control of logging verbosity, so that any messages below the configured logging level will not be written to the log. The logging level and file are initially set when an adapter first starts up – see Logging configuration (optional) for more information about the logging configuration.
The C/C++ interface to the logging system is declared in the header file AP_Logger.h, which can be found in the include directory of the Apama installation. All users of the logging system should include this header file. The types and functions of interest to IAF plug-in writers are:
AP_LogLevel

/**
* Enumeration of logging verbosity levels. In order of increasing verbosity,
* the levels are: NULL < OFF < CRIT < FATAL < ERROR < WARN < INFO <
* DEBUG < TRACE.
* Messages logged at level X will be sent to the log if the current
* level is >= X.
*/
enum AP_LogLevel {
  AP_LogLevel_NULL,
  AP_LogLevel_OFF,
  AP_LogLevel_CRIT,
  AP_LogLevel_FATAL,
  AP_LogLevel_ERROR,
  AP_LogLevel_WARN,
  AP_LogLevel_INFO,
  AP_LogLevel_DEBUG,
AP_LogLevel_TRACE
};
Note:  
AP_LogLevel_NULL means “no log level has been set” and should be interpreted by IAF and plug-ins as “use the default logging level.”
AP_LogTrace
 
/**
   * Log a message at TRACE level. Note that the message will only appear
   * in the log file if the current logging level is AP_LogLevel_Trace.
   *
   * @param message The message to be logged. This is a standard printf()
   * format string; any values required by the formatting should be passed
   * as additional arguments to the AP_LogTrace() call.
   */
AP_COMMON_API void AP_COMMON_CALL AP_LogTrace(const char* message, ...);
Along with the other logging functions described below, AP_LogTrace is based on the standard C library printf function. The message parameter may contain printf formatting characters that will be filled in from the remaining arguments.
AP_LogDebug
 
/**
   * Log a message at DEBUG level. Note that the message will only appear
   * in the log file if the current logging level is AP_LogLevel_DEBUG or
   * greater.
   *
   * @param message The message to be logged. This is a standard printf()
   * format string; any values required by the formatting should be passed
   * as additional arguments to the AP_LogDebug() call.
   */
AP_COMMON_API void AP_COMMON_CALL AP_LogDebug(const char* message, ...);
AP_LogInfo
 
/**
  * Log a message at INFO level. Note that the message will only appear
  * in the log file if the current logging level is AP_LogLevel_INFO or
  * greater.
  *
   * @param message The message to be logged. This is a standard printf()
   * format string; any values required by the formatting should be passed
   * as additional arguments to the AP_LogInfo() call.
   */
AP_COMMON_API void AP_COMMON_CALL AP_LogInfo(const char* message, ...);
 
AP_LogWarn
 
/**
   * Log a message at WARN level. Note that the message will only appear
   * in the log file if the current logging level is AP_LogLevel_WARN or
   * greater.
   *
   * @param message The message to be logged. This is a standard printf()
   * format string; any values required by the formatting should be passed
   * as additional arguments to the AP_LogWarn() call.
   */
AP_COMMON_API void AP_COMMON_CALL AP_LogWarn(const char* message, ...);
 
AP_LogError
 
/**
   * Log a message at ERROR level. Note that the message will only appear
   * in the log file if the current logging level is AP_LogLevel_ERROR or
   * greater.
   *
   * @param message The message to be logged. This is a standard printf()
   * format string; any values required by the formatting should be passed
   * as additional arguments to the AP_LogError() call.
   */
AP_COMMON_API void AP_COMMON_CALL AP_LogError(const char* message, ...);
 
AP_LogCrit
 
/**
   * Log a message at CRIT level. Note that the message will only appear
   * in the log file if the current logging level is AP_LogLevel_CRIT or
   * greater.
   *
   * @param message The message to be logged. This is a standard printf()
   * format string; any values required by the formatting should be passed
   * as additional arguments to the AP_LogCrit() call.
   */
AP_COMMON_API void AP_COMMON_CALL AP_LogCrit(const char* message, ...);
The logging API offers other functions to set and query the current logging level and output file. While these functions are available to plug-in code, it is recommended that plug-ins do not use them. The IAF core is responsible for updating the state of the logging system in response to adapter re-configuration requests.
Copyright © 2013-2017 Software AG, Darmstadt, Germany. (Innovation Release)

Product LogoContact Support   |   Community   |   Feedback