Vuo
2.1.2
library
VuoLog.h
Go to the documentation of this file.
1
10
// Don't use `#pragma once` here, since this header is included both from the source tree and from Vuo.framework.
11
#ifndef VUO_LOG
12
#define VUO_LOG
13
14
#ifdef __cplusplus
15
extern
"C"
{
16
#endif
17
18
#include <stdbool.h>
19
28
double
VuoLogGetTime
(
void
);
29
double
VuoLogGetElapsedTime
(
void
);
30
bool
VuoIsDebugEnabled
(
void
);
31
32
void
VuoLog_backtrace
(
void
);
33
#ifdef __cplusplus
34
}
35
#include <vector>
36
std::vector<std::string>
VuoLog_getBacktrace
(
void
);
37
extern
"C"
{
38
#endif
39
40
51
#define VuoLog_status(format, ...) VuoLog_statusF(__FILE__, __LINE__, __func__, format, ##__VA_ARGS__)
52
56
#ifdef DOXYGEN
57
void
VuoLog_statusF
(
const
char
*file,
const
unsigned
int
linenumber,
const
char
*
function
,
const
char
*format, ...);
58
#else
59
void
VuoLog_statusF
(
const
char
*file,
const
unsigned
int
linenumber,
const
char
*
function
,
const
char
*format, ...) __attribute__((format(printf, 4, 5)));
60
#endif
61
67
#ifdef DOXYGEN
68
void
VuoLog
(
const
char
*file,
const
unsigned
int
linenumber,
const
char
*
function
,
const
char
*format, ...);
69
#else
70
void
VuoLog
(
const
char
*file,
const
unsigned
int
linenumber,
const
char
*
function
,
const
char
*format, ...) __attribute__((format(printf, 4, 5)));
71
#endif
72
85
#define VL() VuoLog(__FILE__, __LINE__, __func__, "")
86
101
#define VLog(format, ...) VuoLog(__FILE__, __LINE__, __func__, format, ##__VA_ARGS__)
102
108
#define VUserLog(format, ...) VuoLog(__FILE__, __LINE__, __func__, format, ##__VA_ARGS__)
109
115
#define VDebugLog(format, ...) do { if (VuoIsDebugEnabled()) VuoLog(__FILE__, __LINE__, __func__, format, ##__VA_ARGS__); } while(0)
116
129
#define VLogHeap(heapPointer) do { \
130
char *description = VuoHeap_getDescription(heapPointer); \
131
VLog("%s = %p (registered at %s)", #heapPointer, heapPointer, description); \
132
free(description); \
133
} while(0)
134
135
136
void
VuoLog_recordTime
(
const
char
*name,
double
time);
137
138
#ifdef VUO_PROFILE
139
#define VUOLOG_PROFILE_BEGIN(object) double VuoLog_time_ ## object = VuoLogGetTime();
140
#define VUOLOG_PROFILE_END(object) VuoLog_recordTime(#object, VuoLogGetTime() - VuoLog_time_ ## object);
141
#else
142
153
#define VUOLOG_PROFILE_BEGIN(object)
154
158
#define VUOLOG_PROFILE_END(object)
159
#endif
160
173
#ifndef DOXYGEN
174
// Executes the block passed to it (an adapter in order to use `__attribute__((cleanup(…)))` with C Blocks).
175
static
inline
void
VuoDeferCleanup(
void
(^*b)(
void
)) {
if
(*b) (*b)(); }
176
177
// Combines two strings into an identifier.
178
#define VuoDeferMerge(a,b) a##b
179
180
// Create the name of the defer scope variable.
181
#define VuoDeferVarName(a) VuoDeferMerge(VuoDeferScopeVar, a)
182
#endif
183
198
#define VuoDefer __attribute__((cleanup(VuoDeferCleanup),unused)) void (^VuoDeferVarName(__COUNTER__))(void) =
199
204
#ifdef __cplusplus
205
}
206
#endif
207
208
#endif
Generated on Tue Jul 14 2020 23:19:37 for Vuo by
1.8.18