27using LogFields = std::vector<std::pair<std::string, std::string>>;
31 static void init(
const std::string& level_str);
32 static void log(
LogLevel level,
const char* file,
int line,
const std::string& msg);
45 using Sink = std::function<void(
const std::string& line)>;
68#define ORBIT_LOG_AT(level, msg) do { if (::orbit::utils::Logger::current_level <= (level)) { std::ostringstream orbit_log_stream_; orbit_log_stream_ << msg; ::orbit::utils::Logger::log((level), __FILE__, __LINE__, orbit_log_stream_.str()); } } while(0)
69#define LOG_DEBUG(msg) ORBIT_LOG_AT(::orbit::utils::log_levels::kDebug, msg)
70#define LOG_INFO(msg) ORBIT_LOG_AT(::orbit::utils::log_levels::kInfo, msg)
71#define LOG_WARN(msg) ORBIT_LOG_AT(::orbit::utils::log_levels::kWarn, msg)
72#define LOG_ERROR(msg) ORBIT_LOG_AT(::orbit::utils::log_levels::kError, msg)
std::function< void(const std::string &line)> Sink
Definition Logger.hpp:45
static std::string level_to_string(LogLevel level, bool color)
static void log(LogLevel level, const char *file, int line, const std::string &msg)
static void set_sink(Sink sink)
static void set_format(const std::string &format)
Parses "text" or "json" (case-insensitive); anything else keeps the current format.
static LogLevel current_level
Definition Logger.hpp:48
static void init(const std::string &level_str)
static void set_format(LogFormat format)
static LogFormat format()
static void log_fields(LogLevel level, const char *file, int line, const std::string &msg, const LogFields &fields)
static std::mutex log_mutex
Definition Logger.hpp:50
constexpr LogLevel kDebug
Definition Logger.hpp:62
constexpr LogLevel kInfo
Definition Logger.hpp:63
constexpr LogLevel kWarn
Definition Logger.hpp:64
constexpr LogLevel kError
Definition Logger.hpp:65
Definition legacy_namespaces.hpp:26
LogFormat
Definition Logger.hpp:25
LogLevel
Definition Logger.hpp:16
std::vector< std::pair< std::string, std::string > > LogFields
Definition Logger.hpp:27