VaneDB 0.1.0
Embeddable vector database for edge AI
Loading...
Searching...
No Matches
Namespaces | Macros | Enumerations | Functions
logging.h File Reference

Lightweight structured logging for VaneDB. More...

#include <chrono>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <mutex>
#include <sstream>
#include <string>

Go to the source code of this file.

Namespaces

namespace  vanedb
 
namespace  vanedb::logging
 

Macros

#define VANEDB_LOG(level, msg, ...)    ::vanedb::logging::log(level, __FILE__, __LINE__, msg, ##__VA_ARGS__)
 
#define VANEDB_LOG_TRACE(msg, ...)    VANEDB_LOG(::vanedb::logging::Level::TRACE, msg, ##__VA_ARGS__)
 
#define VANEDB_LOG_DEBUG(msg, ...)    VANEDB_LOG(::vanedb::logging::Level::DEBUG, msg, ##__VA_ARGS__)
 
#define VANEDB_LOG_INFO(msg, ...)    VANEDB_LOG(::vanedb::logging::Level::INFO, msg, ##__VA_ARGS__)
 
#define VANEDB_LOG_WARN(msg, ...)    VANEDB_LOG(::vanedb::logging::Level::WARN, msg, ##__VA_ARGS__)
 
#define VANEDB_LOG_ERROR(msg, ...)    VANEDB_LOG(::vanedb::logging::Level::ERROR, msg, ##__VA_ARGS__)
 

Enumerations

enum class  vanedb::logging::Level {
  vanedb::logging::TRACE = 0 , vanedb::logging::DEBUG = 1 , vanedb::logging::INFO = 2 , vanedb::logging::WARN = 3 ,
  vanedb::logging::ERROR = 4 , vanedb::logging::OFF = 5
}
 Log level enumeration. More...
 

Functions

const char * vanedb::logging::level_to_string (Level level)
 Convert log level to string.
 
Levelvanedb::logging::global_level ()
 Global log level (can be changed at runtime).
 
void vanedb::logging::set_level (Level level)
 Set the global log level.
 
Level vanedb::logging::get_level ()
 Get the global log level.
 
std::mutex & vanedb::logging::log_mutex ()
 Mutex for thread-safe logging.
 
template<typename T >
void vanedb::logging::format_kv (std::ostringstream &ss, const char *key, const T &value)
 Format a single key-value pair.
 
void vanedb::logging::format_kvs (std::ostringstream &)
 Format key-value pairs (base case).
 
template<typename V , typename... Args>
void vanedb::logging::format_kvs (std::ostringstream &ss, const char *key, const V &value, Args &&... args)
 Format key-value pairs (recursive case).
 
template<typename... Args>
void vanedb::logging::log (Level level, const char *file, int line, const char *message, Args &&... args)
 Core logging function.
 

Detailed Description

Lightweight structured logging for VaneDB.

Simple, header-only logging utility that supports:

Usage: VANEDB_LOG_INFO("Operation completed", "vectors", 1000, "latency_ms", 5.2); VANEDB_LOG_ERROR("Index failed", "reason", "dimension_mismatch");

To enable logging, define VANEDB_ENABLE_LOGGING before including this header. Log level can be controlled via VANEDB_LOG_LEVEL_<LEVEL> macros (e.g., VANEDB_LOG_LEVEL_DEBUG; default: INFO).

Definition in file logging.h.

Macro Definition Documentation

◆ VANEDB_LOG

#define VANEDB_LOG (   level,
  msg,
  ... 
)     ::vanedb::logging::log(level, __FILE__, __LINE__, msg, ##__VA_ARGS__)

Definition at line 177 of file logging.h.

◆ VANEDB_LOG_DEBUG

#define VANEDB_LOG_DEBUG (   msg,
  ... 
)     VANEDB_LOG(::vanedb::logging::Level::DEBUG, msg, ##__VA_ARGS__)

Definition at line 183 of file logging.h.

◆ VANEDB_LOG_ERROR

#define VANEDB_LOG_ERROR (   msg,
  ... 
)     VANEDB_LOG(::vanedb::logging::Level::ERROR, msg, ##__VA_ARGS__)

Definition at line 192 of file logging.h.

◆ VANEDB_LOG_INFO

#define VANEDB_LOG_INFO (   msg,
  ... 
)     VANEDB_LOG(::vanedb::logging::Level::INFO, msg, ##__VA_ARGS__)

Definition at line 186 of file logging.h.

◆ VANEDB_LOG_TRACE

#define VANEDB_LOG_TRACE (   msg,
  ... 
)     VANEDB_LOG(::vanedb::logging::Level::TRACE, msg, ##__VA_ARGS__)

Definition at line 180 of file logging.h.

◆ VANEDB_LOG_WARN

#define VANEDB_LOG_WARN (   msg,
  ... 
)     VANEDB_LOG(::vanedb::logging::Level::WARN, msg, ##__VA_ARGS__)

Definition at line 189 of file logging.h.