All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
as_log Struct Reference

Detailed Description

Aerospike Client exposed logging functionality including:

  • Ability to control the verbosity of log messages.
  • Direct where log messages are sent to.

Setting Log Level

To set the log level for the aerospike client, simply use as_log_set_level() and pass in the client log to set.

@ AS_LOG_LEVEL_INFO
Definition as_log.h:36
static void as_log_set_level(as_log_level level)
Definition as_log.h:160

Redirecting Log Output

By default, the logger is not enabled.

To enable where log messages are sent, simply define a new as_log_callback, and set it for the client using as_log_set_callback():

as_log_set_callback(my_log_callback);
static void as_log_set_callback(as_log_callback callback)
Definition as_log.h:174

Where the my_log_callback could be defined as

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;
}
as_log_level
Definition as_log.h:33
as_log_level level
Definition as_log.h:127

Definition at line 122 of file as_log.h.

#include "as_log.h"

+ Collaboration diagram for as_log:

Data Fields

as_log_callback callback
 
bool callback_set
 
as_log_level level
 

Related Symbols

(Note that these are not member symbols.)

typedef bool(* as_log_callback) (as_log_level level, const char *func, const char *file, uint32_t line, const char *fmt,...)
 
static const char * as_log_level_tostring (as_log_level level)
 
static void as_log_set_callback (as_log_callback callback)
 
static void as_log_set_level (as_log_level level)
 

Friends And Related Symbol Documentation

◆ as_log_callback

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

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 75 of file as_log.h.

◆ as_log_level_tostring()

static const char * as_log_level_tostring ( as_log_level level)
related

Convert log level to a string.

Parameters
levelThe log level.

Definition at line 188 of file as_log.h.

References as_log_level_strings.

◆ as_log_set_callback()

static void as_log_set_callback ( as_log_callback callback)
related

Set logging callback for the global client log. To silence the log, set callback to NULL.

Parameters
callbackThe log callback.

Definition at line 174 of file as_log.h.

References callback, callback_set, and g_as_log.

◆ as_log_set_level()

static void as_log_set_level ( as_log_level level)
related

Set logging level for the global client log.

Parameters
levelThe log level.

Definition at line 160 of file as_log.h.

References g_as_log, and level.

Field Documentation

◆ callback

as_log_callback as_log::callback

Logging Callback

Definition at line 137 of file as_log.h.

◆ callback_set

bool as_log::callback_set

Was callback explicitly set.

Definition at line 132 of file as_log.h.

◆ level

as_log_level as_log::level

Log Level

Definition at line 127 of file as_log.h.


The documentation for this struct was generated from the following file: