#include <aerospike/as_std.h>
#include <stdarg.h>
Go to the source code of this file.
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
-
level | The log level of the message. |
func | The function where the message was logged. |
file | The file where the message was logged. |
line | The line where the message was logged. |
fmt | The format string used. |
... | The format argument. |
- Returns
- true if the message was logged. Otherwise false.
Definition at line 77 of file as_log.h.
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.