All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Data Structures | Typedefs | Enumerations | Variables
as_log.h File Reference
#include <aerospike/as_std.h>
#include <stdarg.h>
+ Include dependency graph for as_log.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  as_log
 

Typedefs

typedef bool(* as_log_callback )(as_log_level level, const char *func, const char *file, uint32_t line, const char *fmt,...)
 

Enumerations

enum  as_log_level {
  AS_LOG_LEVEL_ERROR = 0, AS_LOG_LEVEL_WARN = 1, AS_LOG_LEVEL_INFO = 2, AS_LOG_LEVEL_DEBUG = 3,
  AS_LOG_LEVEL_TRACE = 4
}
 

Variables

AS_EXTERN const char * as_log_level_strings []
 
AS_EXTERN as_log g_as_log
 

Typedef Documentation

typedef bool(* as_log_callback)(as_log_level level, const char *func, const char *file, uint32_t line, const char *fmt,...)

Callback function for as_log related logging calls.

The following is a simple log callback:

bool my_log_callback(
as_log_level level, const char * func, const char * file, uint32_t line,
const char * fmt, ...)
{
char msg[1024] = {0};
va_list ap;
va_start(ap, fmt);
vsnprintf(msg, 1024, fmt, ap);
msg[1023] = '\0';
va_end(ap);
fprintf(stderr, "[%s:%d][%s] %d - %s\n", file, line, func, level, msg);
return true;
}

The function should return true on success.

Parameters
levelThe log level of the message.
funcThe function where the message was logged.
fileThe file where the message was logged.
lineThe line where the message was logged.
fmtThe format string used.
...The format argument.
Returns
true if the message was logged. Otherwise false.

Definition at line 77 of file as_log.h.

Enumeration Type Documentation

Log Level

Enumerator
AS_LOG_LEVEL_ERROR 
AS_LOG_LEVEL_WARN 
AS_LOG_LEVEL_INFO 
AS_LOG_LEVEL_DEBUG 
AS_LOG_LEVEL_TRACE 

Definition at line 33 of file as_log.h.

Variable Documentation

AS_EXTERN const char* as_log_level_strings[]
AS_EXTERN as_log g_as_log