duvc-ctl 2.0.0
USB Video Class Camera Control Library
Loading...
Searching...
No Matches
logging.h
Go to the documentation of this file.
1#pragma once
2
8#include <functional>
9#include <string>
10
11namespace duvc {
12
16enum class LogLevel {
17 Debug = 0,
18 Info = 1,
19 Warning = 2,
20 Error = 3,
21 Critical = 4
22};
23
29const char *to_string(LogLevel level);
30
37 std::function<void(LogLevel level, const std::string &message)>;
38
44
50
56
62void log_message(LogLevel level, const std::string &message);
63
68void log_debug(const std::string &message);
69
74void log_info(const std::string &message);
75
80void log_warning(const std::string &message);
81
86void log_error(const std::string &message);
87
92void log_critical(const std::string &message);
93
94// Convenience macros for formatted logging
95
101#define DUVC_LOG_DEBUG(msg) duvc::log_debug(msg)
102
108#define DUVC_LOG_INFO(msg) duvc::log_info(msg)
109
115#define DUVC_LOG_WARNING(msg) duvc::log_warning(msg)
116
122#define DUVC_LOG_ERROR(msg) duvc::log_error(msg)
123
129#define DUVC_LOG_CRITICAL(msg) duvc::log_critical(msg)
130
131} // namespace duvc
Error information with context.
Definition result.h:41
Result type that can contain either a value or an error.
Definition result.h:75
Definition core.h:13
void log_info(const std::string &message)
Log info message.
Definition logging.cpp:114
std::function< void(LogLevel level, const std::string &message)> LogCallback
Log message callback type.
Definition logging.h:36
void log_debug(const std::string &message)
Log debug message.
Definition logging.cpp:110
LogLevel
Log levels.
Definition logging.h:16
@ Warning
Warning messages.
@ Critical
Critical errors.
@ Info
Informational messages.
@ Debug
Debug information.
void log_error(const std::string &message)
Log error message.
Definition logging.cpp:122
void set_log_callback(LogCallback callback)
Set global log callback.
Definition logging.cpp:73
const char * to_string(CamProp)
Convert camera property enum to string.
Definition core.cpp:678
void log_message(LogLevel level, const std::string &message)
Log a message.
Definition logging.cpp:88
void log_warning(const std::string &message)
Log warning message.
Definition logging.cpp:118
void log_critical(const std::string &message)
Log critical message.
Definition logging.cpp:126
void set_log_level(LogLevel level)
Set minimum log level.
Definition logging.cpp:78
LogLevel get_log_level()
Get current minimum log level.
Definition logging.cpp:83