Time-of-Flight Library(ToF) 4.0.1
 
log.h
1#ifndef _CHRONOPTICS_TOF_LOG_H_
2#define _CHRONOPTICS_TOF_LOG_H_
3
4#include <chronoptics/tof/error.h>
5
6#ifdef __cplusplus
7extern "C" {
8#endif
9
10/** Function pointer type for log callback
11 * @param log_msg String containing log messages
12 * @param user_data The passed back user data
13 */
14typedef void (*tof_log_callback_t)(const char* log_msg, void* user_data);
15
16/** Function pointer type for log callback separated
17 * @param level Log level. Info 2, Warning 3, Error 4, Critical 5
18 * @param logger_name The name of the logger
19 * @param msg Actual message
20 * @param user_data The passed back user data
21 */
22typedef void (*tof_log_callback_separated_t)(int16_t level, const char* logger_name, const char* msg, void* user_data);
23
24/** Class containing log information about the crash that occurred
25 */
26typedef struct tof_crash_report* tof_crash_report_t;
27
28typedef struct tof_crash_report const* tof_crash_report_ct;
29
30/** Destruct tof_crash_report */
31TOF_EXPORT void tof_crash_report_delete(tof_crash_report_t ptr);
32
33/** Generate crash report on a camera
34 * @param ptr Pointer to class
35 * @param serial Camera to generate the crash report on
36 * @param description Description of what happened
37 * @param error Pointer to error
38 * @return New object
39 */
40TOF_EXPORT tof_crash_report_t tof_crash_report_new(const char* serial, const char* description, tof_error_t *error);
41
42/** Get the description
43 * @param ptr Pointer to class
44 * @param error Pointer to error
45 * @return Description
46 */
47TOF_EXPORT const char* tof_crash_report_get_description(tof_crash_report_ct ptr, tof_error_t *error);
48
49/** Set the description
50 * @param ptr Pointer to class
51 * @param description Description
52 * @param error Pointer to error
53 */
54TOF_EXPORT void tof_crash_report_set_description(tof_crash_report_t ptr, const char* description, tof_error_t *error);
55
56/** Get the complete report
57 * @param ptr Pointer to class
58 * @param error Pointer to error
59 * @return String of the entire report
60 */
61TOF_EXPORT const char* tof_crash_report_get_report(tof_crash_report_ct ptr, tof_error_t *error);
62
63/** Save report to disk
64 * @param ptr Pointer to class
65 * @param file_name File to save the report to
66 * @param error Pointer to error
67 */
68TOF_EXPORT void tof_crash_report_save(tof_crash_report_ct ptr, const char* file_name, tof_error_t *error);
69
70/** Get the version of the tof library
71 * @param error Pointer to error
72 * @return Library version
73 */
74TOF_EXPORT const char* tof_get_version(tof_error_t *error);
75
76/** Log info/warning/error occuring in the tof library to stdout
77 * @param error Pointer to error
78 */
79TOF_EXPORT void tof_log_to_console(tof_error_t *error);
80
81/** Log info/warning/error occuring in the tof library
82 * @param file_location Location where to store the log file
83 * @param error Pointer to error
84 */
85TOF_EXPORT void tof_log_to_file(const char* file_location, tof_error_t *error);
86
87/** Log info/warning/error occuring in the tof library to function
88 * @param callback Function that is called with log data
89 * @param callback_user_data User data that will be passed back when the function pointer is called
90 * @param error Pointer to error
91 */
92TOF_EXPORT void tof_log_callback(tof_log_callback_t callback, void* callback_user_data, tof_error_t *error);
93
94/** Log info/warning/error occuring in the tof library to function
95 * @param callback_separated Function that is called with separated log data
96 * @param callback_separated_user_data User data that will be passed back when the function pointer is called
97 * @param error Pointer to error
98 */
99TOF_EXPORT void tof_log_callback_separated(tof_log_callback_separated_t callback_separated, void* callback_separated_user_data, tof_error_t *error);
100
101/** Stop logging
102 * @param error Pointer to error
103 */
104TOF_EXPORT void tof_log_drop(tof_error_t *error);
105
106#ifdef __cplusplus
107}
108#endif
109
110#endif