All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Data Structures | Macros | Enumerations | Functions
src/include/aerospike/as_logger.h File Reference
#include <stdlib.h>
#include <stdarg.h>
#include <stdbool.h>
+ Include dependency graph for src/include/aerospike/as_logger.h:

Go to the source code of this file.

Data Structures

struct  as_logger
 
struct  as_logger_hooks
 

Macros

#define as_logger_debug(__logger, __message, __args...)   as_logger_log(__logger, AS_LOGGER_LEVEL_DEBUG, __FILE__, __LINE__, __message, ##__args)
 
#define as_logger_debug_enabled(__logger)   as_logger_enabled(__logger, AS_LOGGER_LEVEL_DEBUG)
 
#define as_logger_error(__logger, __message, __args...)   as_logger_log(__logger, AS_LOGGER_LEVEL_ERROR, __FILE__, __LINE__, __message, ##__args)
 
#define as_logger_error_enabled(__logger)   as_logger_enabled(__logger, AS_LOGGER_LEVEL_ERROR)
 
#define as_logger_info(__logger, __message, __args...)   as_logger_log(__logger, AS_LOGGER_LEVEL_INFO, __FILE__, __LINE__, __message, ##__args)
 
#define as_logger_info_enabled(__logger)   as_logger_enabled(__logger, AS_LOGGER_LEVEL_INFO)
 
#define as_logger_trace(__logger, __message, __args...)   as_logger_log(__logger, AS_LOGGER_LEVEL_TRACE, __FILE__, __LINE__, __message, ##__args)
 
#define as_logger_trace_enabled(__logger)   as_logger_enabled(__logger, AS_LOGGER_LEVEL_TRACE)
 
#define as_logger_warn(__logger, __message, __args...)   as_logger_log(__logger, AS_LOGGER_LEVEL_WARN, __FILE__, __LINE__, __message, ##__args)
 
#define as_logger_warn_enabled(__logger)   as_logger_enabled(__logger, AS_LOGGER_LEVEL_WARN)
 

Enumerations

enum  as_logger_level {
  AS_LOGGER_LEVEL_TRACE = 0, AS_LOGGER_LEVEL_DEBUG = 1, AS_LOGGER_LEVEL_INFO = 2, AS_LOGGER_LEVEL_WARN = 3,
  AS_LOGGER_LEVEL_ERROR = 4, AS_LOGGER_LEVEL_TRACE = 0, AS_LOGGER_LEVEL_DEBUG = 1, AS_LOGGER_LEVEL_INFO = 2,
  AS_LOGGER_LEVEL_WARN = 3, AS_LOGGER_LEVEL_ERROR = 4
}
 

Functions

int as_logger_destroy (as_logger *logger)
 
as_logger_level as_logger_get_level (const as_logger *logger)
 
as_loggeras_logger_init (as_logger *logger, void *source, const as_logger_hooks *hooks)
 
bool as_logger_is_enabled (const as_logger *logger, const as_logger_level level)
 
int as_logger_log (const as_logger *logger, const as_logger_level level, const char *file, const int line, const char *format,...)
 
as_loggeras_logger_new (void *source, const as_logger_hooks *hooks)
 

Macro Definition Documentation

#define as_logger_debug (   __logger,
  __message,
  __args... 
)    as_logger_log(__logger, AS_LOGGER_LEVEL_DEBUG, __FILE__, __LINE__, __message, ##__args)

Log an AS_LOG_DEBUG message

Definition at line 72 of file src/include/aerospike/as_logger.h.

#define as_logger_debug_enabled (   __logger)    as_logger_enabled(__logger, AS_LOGGER_LEVEL_DEBUG)

Test if logging of AS_LOG_DEBUG message is enabled

Definition at line 41 of file src/include/aerospike/as_logger.h.

#define as_logger_error (   __logger,
  __message,
  __args... 
)    as_logger_log(__logger, AS_LOGGER_LEVEL_ERROR, __FILE__, __LINE__, __message, ##__args)

Log an AS_LOG_ERROR message

Definition at line 90 of file src/include/aerospike/as_logger.h.

#define as_logger_error_enabled (   __logger)    as_logger_enabled(__logger, AS_LOGGER_LEVEL_ERROR)

Test if logging of AS_LOG_ERROR message is enabled

Definition at line 59 of file src/include/aerospike/as_logger.h.

#define as_logger_info (   __logger,
  __message,
  __args... 
)    as_logger_log(__logger, AS_LOGGER_LEVEL_INFO, __FILE__, __LINE__, __message, ##__args)

Log an AS_LOG_INFO message

Definition at line 78 of file src/include/aerospike/as_logger.h.

#define as_logger_info_enabled (   __logger)    as_logger_enabled(__logger, AS_LOGGER_LEVEL_INFO)

Test if logging of AS_LOG_INFO message is enabled

Definition at line 47 of file src/include/aerospike/as_logger.h.

#define as_logger_trace (   __logger,
  __message,
  __args... 
)    as_logger_log(__logger, AS_LOGGER_LEVEL_TRACE, __FILE__, __LINE__, __message, ##__args)

Log an AS_LOG_ERROR message

Definition at line 66 of file src/include/aerospike/as_logger.h.

#define as_logger_trace_enabled (   __logger)    as_logger_enabled(__logger, AS_LOGGER_LEVEL_TRACE)

Test if logging of AS_LOG_TRACE message is enabled

Definition at line 35 of file src/include/aerospike/as_logger.h.

#define as_logger_warn (   __logger,
  __message,
  __args... 
)    as_logger_log(__logger, AS_LOGGER_LEVEL_WARN, __FILE__, __LINE__, __message, ##__args)

Log an AS_LOG_WARN message

Definition at line 84 of file src/include/aerospike/as_logger.h.

#define as_logger_warn_enabled (   __logger)    as_logger_enabled(__logger, AS_LOGGER_LEVEL_WARN)

Test if logging of AS_LOG_WARN message is enabled

Definition at line 53 of file src/include/aerospike/as_logger.h.

Enumeration Type Documentation

The supported logging levels

Enumerator
AS_LOGGER_LEVEL_TRACE 
AS_LOGGER_LEVEL_DEBUG 
AS_LOGGER_LEVEL_INFO 
AS_LOGGER_LEVEL_WARN 
AS_LOGGER_LEVEL_ERROR 
AS_LOGGER_LEVEL_TRACE 
AS_LOGGER_LEVEL_DEBUG 
AS_LOGGER_LEVEL_INFO 
AS_LOGGER_LEVEL_WARN 
AS_LOGGER_LEVEL_ERROR 

Definition at line 100 of file src/include/aerospike/as_logger.h.

Function Documentation

int as_logger_destroy ( as_logger logger)

Release resources associated with the logger. Calls logger->destroy. If success and if this is a heap allocated logger, then it will be freed.

as_logger_level as_logger_get_level ( const as_logger logger)

Get the current log level for the logger.

as_logger* as_logger_init ( as_logger logger,
void *  source,
const as_logger_hooks hooks 
)

Initialize a stack allocated logger

bool as_logger_is_enabled ( const as_logger logger,
const as_logger_level  level 
)

Test if the log level is enabled for the logger.

For most purposes, you should use the macros:

Usage: if ( as_logger_enabled(logger, AS_LOG_DEBUG) ) { char * foo = tostring(x); as_logger_debug(logger, "foo = %s", foo); cf_free(foo); }

int as_logger_log ( const as_logger logger,
const as_logger_level  level,
const char *  file,
const int  line,
const char *  format,
  ... 
)

Log a message using the logger.

For most purposes, you should use the macros:

  • as_logger_trace(logger, message, ...)
  • as_logger_debug(logger, message, ...)
  • as_logger_info_(logger, message, ...)
  • as_logger_warn_(logger, message, ...)
  • as_logger_error(logger, message, ...)

Usage: as_logger_log(logger, AS_LOG_DEBUG, FILE, LINE, "Hello %s", "Bob");

as_logger* as_logger_new ( void *  source,
const as_logger_hooks hooks 
)

Heap allocate and initialize a logger