VL53L0X API Specification: vl53l0x_platform_log.h Source File

VL53L0X API

vl53l0x_platform_log.h
Go to the documentation of this file.
1 /*******************************************************************************
2 Copyright � 2015, STMicroelectronics International N.V.
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7  * Redistributions of source code must retain the above copyright
8  notice, this list of conditions and the following disclaimer.
9  * Redistributions in binary form must reproduce the above copyright
10  notice, this list of conditions and the following disclaimer in the
11  documentation and/or other materials provided with the distribution.
12  * Neither the name of STMicroelectronics nor the
13  names of its contributors may be used to endorse or promote products
14  derived from this software without specific prior written permission.
15 
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
19 NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS ARE DISCLAIMED.
20 IN NO EVENT SHALL STMICROELECTRONICS INTERNATIONAL N.V. BE LIABLE FOR ANY
21 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 ********************************************************************************/
28 
29 
30 #ifndef _VL53L0X_PLATFORM_LOG_H_
31 #define _VL53L0X_PLATFORM_LOG_H_
32 
33 #include <stdio.h>
34 #include <string.h>
35 /* LOG Functions */
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
47 //#define VL53L0X_LOG_ENABLE 0
48 
49 enum {
57 };
58 
59 enum {
62  TRACE_FUNCTION_ALL = 0x7fffffff //all bits except sign
63 };
64 
65 enum {
69  TRACE_MODULE_ALL = 0x7fffffff //all bits except sign
70 };
71 
72 
73 #ifdef VL53L0X_LOG_ENABLE
74 
75 #include <sys/time.h>
76 
77 extern uint32_t _trace_level;
78 
79 
80 
81 int32_t VL53L0X_trace_config(char *filename, uint32_t modules, uint32_t level, uint32_t functions);
82 
83 void trace_print_module_function(uint32_t module, uint32_t level, uint32_t function, const char *format, ...);
84 
85 
86 //extern FILE * log_file;
87 
88 #define LOG_GET_TIME() (int)clock()
89 
90 #define _LOG_FUNCTION_START(module, fmt, ... ) \
91  trace_print_module_function(module, _trace_level, TRACE_FUNCTION_ALL, "%ld <START> %s "fmt"\n", LOG_GET_TIME(), __FUNCTION__, ##__VA_ARGS__);
92 
93 #define _LOG_FUNCTION_END(module, status, ... )\
94  trace_print_module_function(module, _trace_level, TRACE_FUNCTION_ALL, "%ld <END> %s %d\n", LOG_GET_TIME(), __FUNCTION__, (int)status, ##__VA_ARGS__)
95 
96 #define _LOG_FUNCTION_END_FMT(module, status, fmt, ... )\
97  trace_print_module_function(module, _trace_level, TRACE_FUNCTION_ALL, "%ld <END> %s %d "fmt"\n", LOG_GET_TIME(), __FUNCTION__, (int)status,##__VA_ARGS__)
98 
99 // __func__ is gcc only
100 //#define VL53L0X_ErrLog( fmt, ...) fprintf(stderr, "VL53L0X_ErrLog %s" fmt "\n", __func__, ##__VA_ARGS__)
101 
102 #else /* VL53L0X_LOG_ENABLE no logging */
103  #define VL53L0X_ErrLog(...) (void)0
104  #define _LOG_FUNCTION_START(module, fmt, ... ) (void)0
105  #define _LOG_FUNCTION_END(module, status, ... ) (void)0
106  #define _LOG_FUNCTION_END_FMT(module, status, fmt, ... ) (void)0
107 #endif /* else */
108 
109 #define VL53L0X_COPYSTRING(str, ...) strcpy(str, ##__VA_ARGS__)
110 
111 #ifdef __cplusplus
112 }
113 #endif
114 
115 #endif /* _VL53L0X_PLATFORM_LOG_H_ */
116 
117 
118 
int int32_t
Typedef defining 32 bit int type.
Definition: vl53l0x_types.h:80
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
Definition: vl53l0x_types.h:75