supla-device
Toggle main menu visibility
Loading...
Searching...
No Matches
src
supla
log_wrapper.h
1
/*
2
* Copyright (C) AC SOFTWARE SP. Z O.O
3
*
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU General Public License
6
* as published by the Free Software Foundation; either version 2
7
* of the License, or (at your option) any later version.
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
*/
18
19
#ifndef SRC_SUPLA_LOG_WRAPPER_H_
20
#define SRC_SUPLA_LOG_WRAPPER_H_
21
22
#include <stdarg.h>
23
24
#include <supla-common/log.h>
25
26
// add declaration of methods defined in log.c, but not exposed to log.h
27
extern
"C"
char
supla_log_string(
char
**buffer,
int
*size, va_list va,
28
const
char
*__fmt);
29
extern
"C"
void
supla_vlog(
int
__pri,
const
char
*message);
30
31
#define PRINTF_UINT64_HEX(x) \
32
static_cast<uint32_t>((x) >> 32), static_cast<uint32_t>(x)
33
34
#define SUPLA_LOG_IS_ENABLED(level) supla_log_is_enabled(level)
35
36
#ifdef ARDUINO
37
#include <Arduino.h>
38
39
class
__FlashStringHelper;
40
41
void
supla_logf(
int
__pri,
const
__FlashStringHelper *__fmt, ...);
42
43
#else
44
45
#ifndef F
46
#define F(argument_F) (argument_F)
47
#endif
48
49
#define supla_logf supla_log
50
#endif
51
52
// #define SUPLA_DISABLE_LOGS
53
54
#ifdef SUPLA_DISABLE_LOGS
55
// uncomment below lines to disable certain logs
56
#define SUPLA_LOG_VERBOSE(arg_format, ...) {};
57
#define SUPLA_LOG_DEBUG(arg_format, ...) {};
58
#define SUPLA_LOG_INFO(arg_format, ...) {};
59
#define SUPLA_LOG_WARNING(arg_format, ...) {};
60
#define SUPLA_LOG_ERROR(arg_format, ...) {};
61
#endif
62
63
#ifdef SUPLA_DEVICE_ESP32
64
#include <esp_log.h>
65
extern
const
char
*SUPLA_TAG;
66
void
supla_device_logf(
int
__pri,
const
char
*__fmt, ...);
67
#ifndef SUPLA_LOG_VERBOSE
68
#define SUPLA_LOG_VERBOSE(arg_format, ...) \
69
do { \
70
if (SUPLA_LOG_IS_ENABLED(LOG_VERBOSE)) { \
71
supla_device_logf(LOG_VERBOSE, arg_format, ## __VA_ARGS__); \
72
} \
73
} while (0)
74
#endif
75
76
#ifndef SUPLA_LOG_DEBUG
77
#define SUPLA_LOG_DEBUG(arg_format, ...) \
78
do { \
79
if (SUPLA_LOG_IS_ENABLED(LOG_DEBUG)) { \
80
supla_device_logf(LOG_DEBUG, arg_format, ## __VA_ARGS__); \
81
} \
82
} while (0)
83
#endif
84
85
#ifndef SUPLA_LOG_INFO
86
#define SUPLA_LOG_INFO(arg_format, ...) \
87
do { \
88
if (SUPLA_LOG_IS_ENABLED(LOG_INFO)) { \
89
supla_device_logf(LOG_INFO, arg_format, ## __VA_ARGS__); \
90
} \
91
} while (0)
92
#endif
93
94
#ifndef SUPLA_LOG_WARNING
95
#define SUPLA_LOG_WARNING(arg_format, ...) \
96
do { \
97
if (SUPLA_LOG_IS_ENABLED(LOG_WARNING)) { \
98
supla_device_logf(LOG_WARNING, arg_format, ## __VA_ARGS__); \
99
} \
100
} while (0)
101
#endif
102
103
#ifndef SUPLA_LOG_ERROR
104
#define SUPLA_LOG_ERROR(arg_format, ...) \
105
do { \
106
if (SUPLA_LOG_IS_ENABLED(LOG_ERR)) { \
107
supla_device_logf(LOG_ERR, arg_format, ## __VA_ARGS__); \
108
} \
109
} while (0)
110
#endif
111
112
#endif
113
114
#ifndef SUPLA_LOG_VERBOSE
115
#define SUPLA_LOG_VERBOSE(arg_format, ...) \
116
do { \
117
if (SUPLA_LOG_IS_ENABLED(LOG_VERBOSE)) { \
118
supla_logf(LOG_VERBOSE, F(arg_format) , ## __VA_ARGS__); \
119
} \
120
} while (0)
121
#endif
122
123
#ifndef SUPLA_LOG_DEBUG
124
#define SUPLA_LOG_DEBUG(arg_format, ...) \
125
do { \
126
if (SUPLA_LOG_IS_ENABLED(LOG_DEBUG)) { \
127
supla_logf(LOG_DEBUG, F(arg_format) , ## __VA_ARGS__); \
128
} \
129
} while (0)
130
#endif
131
132
#ifndef SUPLA_LOG_INFO
133
#define SUPLA_LOG_INFO(arg_format, ...) \
134
do { \
135
if (SUPLA_LOG_IS_ENABLED(LOG_INFO)) { \
136
supla_logf(LOG_INFO, F(arg_format) , ## __VA_ARGS__); \
137
} \
138
} while (0)
139
#endif
140
141
#ifndef SUPLA_LOG_WARNING
142
#define SUPLA_LOG_WARNING(arg_format, ...) \
143
do { \
144
if (SUPLA_LOG_IS_ENABLED(LOG_WARNING)) { \
145
supla_logf(LOG_WARNING, F(arg_format) , ## __VA_ARGS__); \
146
} \
147
} while (0)
148
#endif
149
150
#ifndef SUPLA_LOG_ERROR
151
#define SUPLA_LOG_ERROR(arg_format, ...) \
152
do { \
153
if (SUPLA_LOG_IS_ENABLED(LOG_ERR)) { \
154
supla_logf(LOG_ERR, F(arg_format) , ## __VA_ARGS__); \
155
} \
156
} while (0)
157
#endif
158
159
#endif
// SRC_SUPLA_LOG_WRAPPER_H_
Generated by
1.17.0