42 auto now = std::chrono::system_clock::now();
43 auto time_t = std::chrono::system_clock::to_time_t(
now);
44 auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(
45 now.time_since_epoch()) %
48 std::ostringstream
ss;
49 ss << std::put_time(std::localtime(&
time_t),
"%Y-%m-%d %H:%M:%S");
50 ss <<
'.' << std::setfill(
'0') << std::setw(3) <<
ms.count();
60 std::ostringstream
ss;
65 std::cerr <<
ss.str();
68 std::cout <<
ss.str();
103 "Exception in user log callback - " + message);
Result type that can contain either a value or an error.
Structured logging interface for duvc-ctl.
void log_info(const std::string &message)
Log info message.
static std::mutex g_log_mutex
std::function< void(LogLevel level, const std::string &message)> LogCallback
Log message callback type.
void log_debug(const std::string &message)
Log debug message.
static std::string get_timestamp()
Get current timestamp as string.
@ Warning
Warning messages.
@ Critical
Critical errors.
@ Info
Informational messages.
@ Debug
Debug information.
void log_error(const std::string &message)
Log error message.
void set_log_callback(LogCallback callback)
Set global log callback.
static LogCallback g_log_callback
const char * to_string(CamProp)
Convert camera property enum to string.
void log_message(LogLevel level, const std::string &message)
Log a message.
void log_warning(const std::string &message)
Log warning message.
static LogLevel g_min_log_level
static void default_log_callback(LogLevel level, const std::string &message)
Default logging callback that writes to stderr.
void log_critical(const std::string &message)
Log critical message.
void set_log_level(LogLevel level)
Set minimum log level.
LogLevel get_log_level()
Get current minimum log level.