deCONZ C++ API v2.6.1
Loading...
Searching...
No Matches
dbg_trace.h
1#ifndef DECONZ_DBG_TRACE_H
2#define DECONZ_DBG_TRACE_H
3
4/*
5 * Copyright (c) 2012-2023 dresden elektronik ingenieurtechnik gmbh.
6 * All rights reserved.
7 *
8 * The software in this package is published under the terms of the BSD
9 * style license a copy of which has been included with this distribution in
10 * the LICENSE.txt file.
11 *
12 */
13#include "deconz/declspec.h"
14
15#define DBG_INFO 0x00000001
16#define DBG_ERROR 0x00000002
17#define DBG_PROT 0x00000004
18#define DBG_AIR 0x00000008
19#define DBG_WIRE 0x00000010
20#define DBG_PROTBUF 0x00000020
21#define DBG_ZDP 0x00000040
22#define DBG_ZCL 0x00000080
23#define DBG_APS 0x00000100
24#define DBG_PROT_L2 0x00000200
25#define DBG_ZCLDB 0x00000400
26#define DBG_INFO_L2 0x00000800
27#define DBG_HTTP 0x00001000
28#define DBG_TLINK 0x00002000
29#define DBG_ERROR_L2 0x00004000
30#define DBG_OTA 0x00008000
31#define DBG_APS_L2 0x00010000
32#define DBG_MEASURE 0x00020000
33#define DBG_ROUTING 0x00040000
34#define DBG_ZGP 0x00080000
35#define DBG_IAS 0x00100000
36#define DBG_DDF 0x00200000
37#define DBG_DEV 0x00400000
38#define DBG_JS 0x00800000
39
40#define DBG_END 0x01000000
41
42#define CAST_LLD(x) ((long long)(x))
43#define CAST_LLU(x) ((unsigned long long)(x))
44
45#define DBG_Assert(e) ((e) ? true : (DBG_Printf1(DBG_ERROR, "%s,%d: assertion '%s' failed\n", Q_FUNC_INFO, __LINE__, #e), false))
46
47#define FMT_MAC_CAST(mac) ((unsigned long long)(mac))
48#define FMT_MAC "0x%016llX"
49#define FMT_CLUSTER "0x%04" PRIX16
50#define FMT_ATTR "0x%04" PRIX16
51
52
53#define DBG_MEASURE_START(MEAS_ID) \
54 QElapsedTimer MEAS_ID##measTimer; \
55 const char *MEAS_ID##fn = __FUNCTION__; \
56 const int MEAS_ID##line = __LINE__; \
57 MEAS_ID##measTimer.start()
58
59#define DBG_MEASURE_END(MEAS_ID) \
60 if (DBG_IsEnabled(DBG_MEASURE)) { \
61 DBG_Printf1(DBG_MEASURE, "MS " #MEAS_ID " (%s:%d) took %lld ms\n", MEAS_ID##fn, MEAS_ID##line, MEAS_ID##measTimer.elapsed()); \
62 }
63
64#define DBG_Printf(level, ...) \
65 do { \
66 if (DBG_IsEnabled(level)) { DBG_Printf1(level, __VA_ARGS__); } \
67 } while(0)
68
69#ifdef __cplusplus
70
72{
73
74};
75
76extern "C" {
77#endif
78
79DECONZ_DLLSPEC void DBG_Init(void *logfile);
80DECONZ_DLLSPEC void DBG_Destroy();
81DECONZ_DLLSPEC void DBG_Flush();
82DECONZ_DLLSPEC void DBG_FlushLazy();
83DECONZ_DLLSPEC void DBG_WriteString(int level, const char *str);
84DECONZ_DLLSPEC int DBG_Printf1(int level, const char *format, ...)
85#ifndef _WIN32
86#ifdef DECONZ_DEBUG_BUILD
87#ifdef __GNUC__
88 __attribute__ (( format( printf, 2, 3 ) ))
89#endif
90#endif
91#endif
92;
93DECONZ_DLLSPEC void DBG_Enable(int item);
94DECONZ_DLLSPEC void DBG_Disable(int item);
95DECONZ_DLLSPEC int DBG_IsEnabled(int item);
96DECONZ_DLLSPEC unsigned char * DBG_HexToAscii(const void *hex, unsigned length, void *ascii);
97DECONZ_DLLSPEC void DBG_RegisterCallback(void (*cb)(int, const char*));
98DECONZ_DLLSPEC int DBG_ItemFromString(const char *item);
99DECONZ_DLLSPEC int DBG_StringFromItem(const int item, char *buf, unsigned long buflen);
100
101#ifdef __cplusplus
102}
103#endif
104
105#endif // DECONZ_DBG_TRACE_H
Definition dbg_trace.h:72