OpenMAMA
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
log.h File Reference
#include <stdio.h>
#include <mama/config.h>
#include <stdarg.h>
#include "mama/status.h"

Go to the source code of this file.

Typedefs

typedef const char * format
typedef const char va_list ap
typedef const char * message
typedef void(* logSizeCbType )(void)

Enumerations

enum  MamaLogLevel {
  MAMA_LOG_LEVEL_OFF = 0, MAMA_LOG_LEVEL_SEVERE = 1, MAMA_LOG_LEVEL_ERROR = 2, MAMA_LOG_LEVEL_WARN = 3,
  MAMA_LOG_LEVEL_NORMAL = 4, MAMA_LOG_LEVEL_FINE = 5, MAMA_LOG_LEVEL_FINER = 6, MAMA_LOG_LEVEL_FINEST = 7
}
 The level of detail when logging is enabled within the API. More...
enum  mamaLogFilePolicy { LOGFILE_UNBOUNDED = 1, LOGFILE_ROLL = 2, LOGFILE_OVERWRITE = 3, LOGFILE_USER = 4 }
 The policy to control log file size. More...

Functions

typedef void (MAMACALLTYPE *mamaLogCb)(MamaLogLevel level
 The prototype of the MAMA logging functions.
MAMAExpDLL void MAMACALLTYPE mama_logDefault (MamaLogLevel level, const char *format, va_list ap)
 The default logging within the API unless otherwise specified.
MAMAExpDLL void MAMACALLTYPE mama_logDefault2 (MamaLogLevel level, const char *message)
 This second logging function takes only a message and not a format string with a variable argument list.
MAMAExpDLL void mama_logStdout (MamaLogLevel level, const char *format,...)
MAMAExpDLL void MAMACALLTYPE mama_forceLogDefault (MamaLogLevel level, const char *format, va_list ap)
 The default function used within the API for the mama_forceLog function pointer.
MAMAExpDLL mama_status mama_enableLogging (FILE *file, MamaLogLevel level)
 Enable logging.
MAMAExpDLL mama_status mama_logToFile (const char *file, MamaLogLevel level)
 Behaves as mama_enableLogging() but accepts a string representing the file location.
MAMAExpDLL mama_status mama_disableLogging (void)
 Disable logging.
MAMAExpDLL void mama_log (MamaLogLevel level, const char *format,...)
 Used for the majority of logging within the API.
MAMAExpDLL void MAMACALLTYPE mama_log2 (MamaLogLevel level, const char *message)
MAMAExpDLL void mama_logVa (MamaLogLevel level, const char *format, va_list args)
MAMAExpDLL void mama_forceLogVa (const char *format, va_list args)
 Used for the force logging using variable argument parameters.
MAMAExpDLL void mama_forceLog (MamaLogLevel level, const char *format,...)
MAMAExpDLL mama_status mama_setLogCallback (mamaLogCb callback)
 Set the callback to be used for mama_log calls.
MAMAExpDLL mama_status mama_setLogCallback2 (mamaLogCb2 callback)
 Set the callback to be used for mama_log calls.
MAMAExpDLL mama_status mama_setForceLogCallback (mamaLogCb callback)
 Set the callback to be used for mama logging.
MAMAExpDLL mama_status mama_setLogLevel (MamaLogLevel level)
 Sets the log level for Mama.
MAMAExpDLL MamaLogLevel mama_getLogLevel (void)
 Returns the current log level for Mama.
MAMAExpDLL mama_status mama_setLogSize (unsigned long size)
 Set the maxmum size of the log file (bytes).
MAMAExpDLL mama_status mama_setNumLogFiles (int numFiles)
 Set the number of rolled logfiles to keep before overwriting.
MAMAExpDLL mama_status mama_setLogFilePolicy (mamaLogFilePolicy policy)
 Set the policy regarding how to handle files when Max file size is reached.
MAMAExpDLL mama_status mama_setAppendToLogFile (int append)
 Set append to existing log file.
MAMAExpDLL int mama_loggingToFile (void)
 Return status of loggingToFile.
MAMAExpDLL mama_status mama_setLogSizeCb (logSizeCbType logCallbacks)
 Set a callback for when the max log size is reached.
MAMAExpDLL const char * mama_logLevelToString (MamaLogLevel level)
 Return string version of log level.
MAMAExpDLL int mama_tryStringToLogLevel (const char *s, MamaLogLevel *level)
 Try to convert string to log level Return non-zero for success, zero for failure The string comparison is case insensitive.
MAMAExpDLL const char * mama_logPolicyToString (mamaLogFilePolicy level)
 Return string version of log policy.
MAMAExpDLL int mama_tryStringToLogPolicy (const char *s, mamaLogFilePolicy *policy)
 Try to convert string to log policy.
MAMAExpDLL int mama_logIncrementVerbosity (MamaLogLevel *level)
 Increase by one log level the verbosity of a MamaLogLevel variable.
MAMAExpDLL int mama_logDecrementVerbosity (MamaLogLevel *level)
 Decrease by one log level the verbosity of a MamaLogLevel variable.
MAMAExpDLL mama_status mama_logForceRollLogFiles (void)
 Force rolling the log file.
void mama_logDestroy (void)
 Destroy memory held by the logging.
void mama_loginit (void)

Variables

MAMAExpDLL MamaLogLevel gMamaLogLevel
 The current log level within the API.
MAMAExpDLL FILE * gMamaLogFile
 The file to which all logging will be written by default.

Typedef Documentation

typedef const char* format
typedef const char va_list ap
typedef const char* message
typedef void(* logSizeCbType)(void)

Enumeration Type Documentation

The level of detail when logging is enabled within the API.

Enumerator:
MAMA_LOG_LEVEL_OFF 
MAMA_LOG_LEVEL_SEVERE 
MAMA_LOG_LEVEL_ERROR 
MAMA_LOG_LEVEL_WARN 
MAMA_LOG_LEVEL_NORMAL 
MAMA_LOG_LEVEL_FINE 
MAMA_LOG_LEVEL_FINER 
MAMA_LOG_LEVEL_FINEST 

The policy to control log file size.

Enumerator:
LOGFILE_UNBOUNDED 
LOGFILE_ROLL 
LOGFILE_OVERWRITE 
LOGFILE_USER 

Function Documentation

typedef void ( MAMACALLTYPE *  mamaLogCb)

The prototype of the MAMA logging functions.

MAMAExpDLL void MAMACALLTYPE mama_logDefault ( MamaLogLevel  level,
const char *  format,
va_list  ap 
)

The default logging within the API unless otherwise specified.

MAMAExpDLL void MAMACALLTYPE mama_logDefault2 ( MamaLogLevel  level,
const char *  message 
)

This second logging function takes only a message and not a format string with a variable argument list.

It is required for interoperability with all platforms that do not support C variable argument list, (e.g. .Net). Other than that it performs in exactly the same way as the first.

Parameters
level(in) The log level.
message(in) The message to log.
MAMAExpDLL void mama_logStdout ( MamaLogLevel  level,
const char *  format,
  ... 
)
MAMAExpDLL void MAMACALLTYPE mama_forceLogDefault ( MamaLogLevel  level,
const char *  format,
va_list  ap 
)

The default function used within the API for the mama_forceLog function pointer.

MAMAExpDLL mama_status mama_enableLogging ( FILE *  file,
MamaLogLevel  level 
)

Enable logging.

No per-message or per-tick messages appear at WOMBAT_LOG_LEVEL_FINE. WOMBAT_LOG_LEVEL_FINER and WOMBAT_LOG_LEVEL_FINEST provide successively more detailed logging.

Parameters
fileFile to write to.
levelOutput level.
See Also
Level
MAMAExpDLL mama_status mama_logToFile ( const char *  file,
MamaLogLevel  level 
)

Behaves as mama_enableLogging() but accepts a string representing the file location.

Parameters
fileThe path to the file. Can be relative, absolute or on $WOMBAT_PATH.
levelThe level at which the API should log messages.
MAMAExpDLL mama_status mama_disableLogging ( void  )

Disable logging.

MAMAExpDLL void mama_log ( MamaLogLevel  level,
const char *  format,
  ... 
)

Used for the majority of logging within the API.

MAMAExpDLL void MAMACALLTYPE mama_log2 ( MamaLogLevel  level,
const char *  message 
)
MAMAExpDLL void mama_logVa ( MamaLogLevel  level,
const char *  format,
va_list  args 
)
MAMAExpDLL void mama_forceLogVa ( const char *  format,
va_list  args 
)

Used for the force logging using variable argument parameters.

MAMAExpDLL void mama_forceLog ( MamaLogLevel  level,
const char *  format,
  ... 
)
MAMAExpDLL mama_status mama_setLogCallback ( mamaLogCb  callback)

Set the callback to be used for mama_log calls.

If not set then mama_logDefault will be used

MAMAExpDLL mama_status mama_setLogCallback2 ( mamaLogCb2  callback)

Set the callback to be used for mama_log calls.

This function will set a log callback that receives a formatted string and not a variable argument list. This function is used mainly to support managed clients.

Parameters
callback(in) The callback to be used. Pass NULL to restore the mama_logDefault function.
Returns
MAMA_STATUS_OK
MAMAExpDLL mama_status mama_setForceLogCallback ( mamaLogCb  callback)

Set the callback to be used for mama logging.

If not set then mama_ForceLogDefault will be used

MAMAExpDLL mama_status mama_setLogLevel ( MamaLogLevel  level)

Sets the log level for Mama.

MAMAExpDLL MamaLogLevel mama_getLogLevel ( void  )

Returns the current log level for Mama.

MAMAExpDLL mama_status mama_setLogSize ( unsigned long  size)

Set the maxmum size of the log file (bytes).

When this size is reached the logsize callback is called, or if no callback is set then the default action is to overwrite file from the start. Default max size is 500 Mb

MAMAExpDLL mama_status mama_setNumLogFiles ( int  numFiles)

Set the number of rolled logfiles to keep before overwriting.

Default is 10

MAMAExpDLL mama_status mama_setLogFilePolicy ( mamaLogFilePolicy  policy)

Set the policy regarding how to handle files when Max file size is reached.

Default is LOGFILE_UNBOUNDED

MAMAExpDLL mama_status mama_setAppendToLogFile ( int  append)

Set append to existing log file.

MAMAExpDLL int mama_loggingToFile ( void  )

Return status of loggingToFile.

MAMAExpDLL mama_status mama_setLogSizeCb ( logSizeCbType  logCallbacks)

Set a callback for when the max log size is reached.

This can be used to override the default action which is to wrap the file and continue logging at the beginning

MAMAExpDLL const char* mama_logLevelToString ( MamaLogLevel  level)

Return string version of log level.

MAMAExpDLL int mama_tryStringToLogLevel ( const char *  s,
MamaLogLevel level 
)

Try to convert string to log level Return non-zero for success, zero for failure The string comparison is case insensitive.

MAMAExpDLL const char* mama_logPolicyToString ( mamaLogFilePolicy  level)

Return string version of log policy.

MAMAExpDLL int mama_tryStringToLogPolicy ( const char *  s,
mamaLogFilePolicy policy 
)

Try to convert string to log policy.

Return non-zero for success, zero for failure. The string comparison is case insensitive.

MAMAExpDLL int mama_logIncrementVerbosity ( MamaLogLevel level)

Increase by one log level the verbosity of a MamaLogLevel variable.

If the level is already at the maximum verbosity it will be unchanged after calling the function, otherwise the level will be incremented. Returns zero if level is not changed, or non-zero if it is changed If an unrecognized level is passed, the function will return non-zero and the variable will be set to the minimum verbosity

MAMAExpDLL int mama_logDecrementVerbosity ( MamaLogLevel level)

Decrease by one log level the verbosity of a MamaLogLevel variable.

If the level is already at the minimum verbosity it will be unchanged after calling the function, otherwise the level will be decremented. Returns zero if level is not changed, or non-zero if it is changed If an unrecognized level is passed, the function will return non-zero and the variable will be set to the maximum verbosity

MAMAExpDLL mama_status mama_logForceRollLogFiles ( void  )

Force rolling the log file.

Returns
The status of the operation.
void mama_logDestroy ( void  )

Destroy memory held by the logging.

void mama_loginit ( void  )

Variable Documentation

MAMAExpDLL MamaLogLevel gMamaLogLevel

The current log level within the API.

MAMAExpDLL FILE* gMamaLogFile

The file to which all logging will be written by default.



© 2012 Linux Foundation