27 minimum_console_severity = min_severity;
28 minimum_log_severity = std::min(minimum_console_severity, minimum_log_severity);
33 minimum_file_severity = min_severity;
34 log_file.open(file_path, std::ostream::out | std::ostream::app);
35 minimum_log_severity = std::min(minimum_file_severity, minimum_log_severity);
40 minimum_callback_severity = min_severity;
41 this->callback = std::move(callback);
42 minimum_log_severity = std::min(minimum_callback_severity, minimum_log_severity);
47 std::lock_guard<std::mutex> lock(log_mutex);
49 if (static_cast<int>(severity) < minimum_log_severity)
return;
51 std::time_t
t = std::time(
nullptr);
char buffer[20] = {};
const tm* time = std::localtime(&t);
53 std::strftime(buffer,
sizeof(buffer),
"%Y-%m-%d %H:%M:%S", time);
55 if (severity >= minimum_file_severity)
64 default:
throw std::logic_error(
"not a valid severity for log message");
68 if (severity >= minimum_console_severity)
77 default:
throw std::logic_error(
"not a valid severity for log message");
81 if (callback && severity >= minimum_callback_severity)
83 callback->on_event(severity, message.c_str());
static logger_type logger
void log_to_console(rs_log_severity min_severity)
void log(rs_log_severity severity, const std::string &message)
rs_log_severity get_minimum_severity()
GLuint GLsizei const GLchar * message
GLsizei const GLchar *const * string
rs_log_severity minimum_file_severity
void log_to_file(rs_log_severity min_severity, const char *file_path)
rs_log_severity minimum_log_severity
void log_to_console(rs_log_severity min_severity)
void log_to_callback(rs_log_severity min_severity, rs_log_callback *callback)
log_callback_ptr callback
rs_log_severity get_minimum_severity()
std::unique_ptr< rs_log_callback, void(*)(rs_log_callback *)> log_callback_ptr
rs_log_severity minimum_console_severity
rs_log_severity minimum_callback_severity
void log(rs_log_severity severity, const std::string &message)
rs_log_severity
Severity of the librealsense logger.
void log_to_file(rs_log_severity min_severity, const char *file_path)
void log_to_callback(rs_log_severity min_severity, log_callback_ptr callback)