Time-of-Flight Library(ToF)  3.2.2
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
7 extern "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  */
14 typedef 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  */
22 typedef 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  */
26 typedef struct tof_crash_report* tof_crash_report_t;
27 
28 /** Destruct tof_crash_report */
29 TOF_EXPORT void tof_crash_report_delete(tof_crash_report_t ptr);
30 
31 /** Generate crash report on a camera
32  * @param ptr Pointer to class
33  * @param serial Camera to generate the crash report on
34  * @param description Description of what happened
35  * @param error Pointer to error
36  * @return New object
37  */
38 TOF_EXPORT tof_crash_report_t tof_crash_report_new(const char* serial, const char* description, tof_error_t *error);
39 
40 /** Get the description
41  * @param ptr Pointer to class
42  * @param error Pointer to error
43  * @return Description
44  */
45 TOF_EXPORT const char* tof_crash_report_get_description(const tof_crash_report_t ptr, tof_error_t *error);
46 
47 /** Set the description
48  * @param ptr Pointer to class
49  * @param description Description
50  * @param error Pointer to error
51  */
52 TOF_EXPORT void tof_crash_report_set_description(tof_crash_report_t ptr, const char* description, tof_error_t *error);
53 
54 /** Get the complete report
55  * @param ptr Pointer to class
56  * @param error Pointer to error
57  * @return String of the entire report
58  */
59 TOF_EXPORT const char* tof_crash_report_get_report(const tof_crash_report_t ptr, tof_error_t *error);
60 
61 /** Save report to disk
62  * @param ptr Pointer to class
63  * @param file_name File to save the report to
64  * @param error Pointer to error
65  */
66 TOF_EXPORT void tof_crash_report_save(const tof_crash_report_t ptr, const char* file_name, tof_error_t *error);
67 
68 /** Get the version of the tof library
69  * @param error Pointer to error
70  * @return Library version
71  */
72 TOF_EXPORT const char* tof_get_version(tof_error_t *error);
73 
74 /** Log info/warning/error occuring in the tof library to stdout
75  * @param error Pointer to error
76  */
77 TOF_EXPORT void tof_log_to_console(tof_error_t *error);
78 
79 /** Log info/warning/error occuring in the tof library
80  * @param file_location Location where to store the log file
81  * @param error Pointer to error
82  */
83 TOF_EXPORT void tof_log_to_file(const char* file_location, tof_error_t *error);
84 
85 /** Log info/warning/error occuring in the tof library to function
86  * @param callback Function that is called with log data
87  * @param callback_user_data User data that will be passed back when the function pointer is called
88  * @param error Pointer to error
89  */
90 TOF_EXPORT void tof_log_callback(tof_log_callback_t callback, void* callback_user_data, tof_error_t *error);
91 
92 /** Log info/warning/error occuring in the tof library to function
93  * @param callback_separated Function that is called with separated log data
94  * @param callback_separated_user_data User data that will be passed back when the function pointer is called
95  * @param error Pointer to error
96  */
97 TOF_EXPORT void tof_log_callback_separated(tof_log_callback_separated_t callback_separated, void* callback_separated_user_data, tof_error_t *error);
98 
99 /** Stop logging
100  * @param error Pointer to error
101  */
102 TOF_EXPORT void tof_log_drop(tof_error_t *error);
103 
104 #ifdef __cplusplus
105 }
106 #endif
107 
108 #endif