1#ifndef _CHRONOPTICS_TOF_LOG_HPP_
2#define _CHRONOPTICS_TOF_LOG_HPP_
4#include <chronoptics/tof/log.h>
6#include <chronoptics/tof/base.hpp>
12using log_callback_fn = std::function<void(
const char*)>;
13constexpr auto log_callback_cb_handler = &detail::callback_handler<void, const char*>;
16using log_callback_separated_fn = std::function<void(int16_t,
const char*,
const char*)>;
17constexpr auto log_callback_separated_cb_handler = &detail::callback_handler<void, int16_t, const char*, const char*>;
21class CrashReport :
public detail::Base<tof_crash_report, tof_crash_report_delete> {
33 this->ptr_ = tof_crash_report_new(serial, description, TOF_ERROR_HANDLER{});
40 return tof_crash_report_get_description(this->ptr_, TOF_ERROR_HANDLER{});
47 return tof_crash_report_set_description(this->ptr_, description, TOF_ERROR_HANDLER{});
54 return tof_crash_report_get_report(this->ptr_, TOF_ERROR_HANDLER{});
60 void save(StringView file_name)
const {
61 return tof_crash_report_save(this->ptr_, file_name, TOF_ERROR_HANDLER{});
69inline const char* get_version() {
70 return tof_get_version(TOF_ERROR_HANDLER{});
75inline void log_to_console() {
76 return tof_log_to_console(TOF_ERROR_HANDLER{});
82inline void log_to_file(StringView file_location) {
83 return tof_log_to_file(file_location, TOF_ERROR_HANDLER{});
89inline void log_callback(log_callback_fn &callback) {
90 return tof_log_callback(log_callback_cb_handler, &callback, TOF_ERROR_HANDLER{});
97inline void log_callback(tof_log_callback_t callback,
void* callback_user_data) {
98 return tof_log_callback(callback, callback_user_data, TOF_ERROR_HANDLER{});
104inline void log_callback_separated(log_callback_separated_fn &callback_separated) {
105 return tof_log_callback_separated(log_callback_separated_cb_handler, &callback_separated, TOF_ERROR_HANDLER{});
112inline void log_callback_separated(tof_log_callback_separated_t callback_separated,
void* callback_separated_user_data) {
113 return tof_log_callback_separated(callback_separated, callback_separated_user_data, TOF_ERROR_HANDLER{});
118inline void log_drop() {
119 return tof_log_drop(TOF_ERROR_HANDLER{});
Class containing log information about the crash that occurred.
const char * get_report() const
Get the complete report.
void save(StringView file_name) const
Save report to disk.
CrashReport(StringView serial, StringView description)
Generate crash report on a camera.
CrashReport(tof_crash_report_t ptr=nullptr)
Construct from pointer.
void set_description(StringView description)
Set the description.
const char * get_description() const
Get the description.