API — Utilitaires

Module gagent/utils.

ErrorHandler

class ErrorHandler

Error handler utility functions.

Public Static Functions

static bool handleException(const std::exception &e, const std::string &context)

Handle exception and log error.

Paramètres:
  • e – Exception to handle

  • context – Context information

Renvoie:

false to indicate failure

static void logSystemError(const std::string &context)

Log system error with errno.

Paramètres:

context – Context information

Logger

class Logger

Thread-safe logger singleton.

Public Functions

inline void setLogLevel(LogLevel level)
inline bool setLogFile(const std::string &filename)
inline void log(LogLevel level, const std::string &message, const std::string &source = "")
inline void close()
inline void debug(const std::string &msg, const std::string &src = "")
inline void info(const std::string &msg, const std::string &src = "")
inline void warning(const std::string &msg, const std::string &src = "")
inline void error(const std::string &msg, const std::string &src = "")
inline void critical(const std::string &msg, const std::string &src = "")
inline void logJson(const std::string &event, std::initializer_list<std::pair<const char*, std::string>> fields)

Emit one JSON line.

Activated by the GAGENT_LOG env var (set at process start). If GAGENT_LOG is not set the call is a no-op.

Usage: Logger::getInstance().logJson(« acl_send », { {« from », « alice »}, {« to », « bob »}, {« perf », « request »}, {« content », « hello »}, });

Output (one line): {« ts »: »2026-03-24T10:00:00.123Z », »event »: »acl_send », »from »: »alice »,…}

Logger(const Logger&) = delete
Logger &operator=(const Logger&) = delete

Public Static Functions

static inline Logger &getInstance()