Agents 0.0.2
Edge AI Agents SDK
Loading...
Searching...
No Matches
logger.h
1
10#pragma once
11
12#include <fmt/core.h>
13#include <memory>
14#include <string>
15#include <spdlog/spdlog.h>
16#include <spdlog/sinks/stdout_color_sinks.h>
17
18namespace agents {
19
23class Logger {
24public:
58
63 static void init(Level level = Level::INFO);
64
69 static void setLevel(Level level);
70
76 static spdlog::level::level_enum toSpdlogLevel(Level level);
77
83 template<typename... Args>
84 static void trace(fmt::format_string<Args...> fmt, Args&&... args) {
85 spdlog::trace(fmt, std::forward<Args>(args)...);
86 }
87
93 template<typename... Args>
94 static void debug(fmt::format_string<Args...> fmt, Args&&... args) {
95 spdlog::debug(fmt, std::forward<Args>(args)...);
96 }
97
103 template<typename... Args>
104 static void info(fmt::format_string<Args...> fmt, Args&&... args) {
105 spdlog::info(fmt, std::forward<Args>(args)...);
106 }
107
113 template<typename... Args>
114 static void warn(fmt::format_string<Args...> fmt, Args&&... args) {
115 spdlog::warn(fmt, std::forward<Args>(args)...);
116 }
117
123 template<typename... Args>
124 static void error(fmt::format_string<Args...> fmt, Args&&... args) {
125 spdlog::error(fmt, std::forward<Args>(args)...);
126 }
127
133 template<typename... Args>
134 static void critical(fmt::format_string<Args...> fmt, Args&&... args) {
135 spdlog::critical(fmt, std::forward<Args>(args)...);
136 }
137
138private:
139 static std::shared_ptr<spdlog::logger> s_logger;
140};
141
142} // namespace agents
Logger utility class that wraps spdlog functionality.
Definition logger.h:23
static void critical(fmt::format_string< Args... > fmt, Args &&... args)
Log a message at critical level.
Definition logger.h:134
static void debug(fmt::format_string< Args... > fmt, Args &&... args)
Log a message at debug level.
Definition logger.h:94
Level
The log level.
Definition logger.h:28
@ TRACE
Trace logging level.
Definition logger.h:32
@ WARN
Warning logging level.
Definition logger.h:44
@ INFO
Info logging level.
Definition logger.h:40
@ OFF
Logging disabled level.
Definition logger.h:56
@ CRITICAL
Critical logging level.
Definition logger.h:52
@ ERROR
Error logging level.
Definition logger.h:48
@ DEBUG
Debug logging level.
Definition logger.h:36
static void error(fmt::format_string< Args... > fmt, Args &&... args)
Log a message at error level.
Definition logger.h:124
static spdlog::level::level_enum toSpdlogLevel(Level level)
Convert Level enum to spdlog level.
static void init(Level level=Level::INFO)
Initialize the logger.
static void setLevel(Level level)
Set the log level.
static void info(fmt::format_string< Args... > fmt, Args &&... args)
Log a message at info level.
Definition logger.h:104
static void warn(fmt::format_string< Args... > fmt, Args &&... args)
Log a message at warn level.
Definition logger.h:114
static void trace(fmt::format_string< Args... > fmt, Args &&... args)
Log a message at trace level.
Definition logger.h:84
Framework Namespace.
Definition agent.h:18