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
#ifndef SUPLA_LOG_VERBOSE
67
#define SUPLA_LOG_VERBOSE(arg_format, ...) \
68
do { \
69
if (SUPLA_LOG_IS_ENABLED(LOG_VERBOSE)) { \
70
ESP_LOGV(SUPLA_TAG, arg_format, ## __VA_ARGS__); \
71
} \
72
} while (0)
73
#endif
74
75
#ifndef SUPLA_LOG_DEBUG
76
#define SUPLA_LOG_DEBUG(arg_format, ...) \
77
do { \
78
if (SUPLA_LOG_IS_ENABLED(LOG_DEBUG)) { \
79
ESP_LOGD(SUPLA_TAG, arg_format, ## __VA_ARGS__); \
80
} \
81
} while (0)
82
#endif
83
84
#ifndef SUPLA_LOG_INFO
85
#define SUPLA_LOG_INFO(arg_format, ...) \
86
do { \
87
if (SUPLA_LOG_IS_ENABLED(LOG_INFO)) { \
88
ESP_LOGI(SUPLA_TAG, arg_format, ## __VA_ARGS__); \
89
} \
90
} while (0)
91
#endif
92
93
#ifndef SUPLA_LOG_WARNING
94
#define SUPLA_LOG_WARNING(arg_format, ...) \
95
do { \
96
if (SUPLA_LOG_IS_ENABLED(LOG_WARNING)) { \
97
ESP_LOGW(SUPLA_TAG, arg_format, ## __VA_ARGS__); \
98
} \
99
} while (0)
100
#endif
101
102
#ifndef SUPLA_LOG_ERROR
103
#define SUPLA_LOG_ERROR(arg_format, ...) \
104
do { \
105
if (SUPLA_LOG_IS_ENABLED(LOG_ERR)) { \
106
ESP_LOGE(SUPLA_TAG, arg_format, ## __VA_ARGS__); \
107
} \
108
} while (0)
109
#endif
110
111
#endif
112
113
#ifndef SUPLA_LOG_VERBOSE
114
#define SUPLA_LOG_VERBOSE(arg_format, ...) \
115
do { \
116
if (SUPLA_LOG_IS_ENABLED(LOG_VERBOSE)) { \
117
supla_logf(LOG_VERBOSE, F(arg_format) , ## __VA_ARGS__); \
118
} \
119
} while (0)
120
#endif
121
122
#ifndef SUPLA_LOG_DEBUG
123
#define SUPLA_LOG_DEBUG(arg_format, ...) \
124
do { \
125
if (SUPLA_LOG_IS_ENABLED(LOG_DEBUG)) { \
126
supla_logf(LOG_DEBUG, F(arg_format) , ## __VA_ARGS__); \
127
} \
128
} while (0)
129
#endif
130
131
#ifndef SUPLA_LOG_INFO
132
#define SUPLA_LOG_INFO(arg_format, ...) \
133
do { \
134
if (SUPLA_LOG_IS_ENABLED(LOG_INFO)) { \
135
supla_logf(LOG_INFO, F(arg_format) , ## __VA_ARGS__); \
136
} \
137
} while (0)
138
#endif
139
140
#ifndef SUPLA_LOG_WARNING
141
#define SUPLA_LOG_WARNING(arg_format, ...) \
142
do { \
143
if (SUPLA_LOG_IS_ENABLED(LOG_WARNING)) { \
144
supla_logf(LOG_WARNING, F(arg_format) , ## __VA_ARGS__); \
145
} \
146
} while (0)
147
#endif
148
149
#ifndef SUPLA_LOG_ERROR
150
#define SUPLA_LOG_ERROR(arg_format, ...) \
151
do { \
152
if (SUPLA_LOG_IS_ENABLED(LOG_ERR)) { \
153
supla_logf(LOG_ERR, F(arg_format) , ## __VA_ARGS__); \
154
} \
155
} while (0)
156
#endif
157
158
#endif
// SRC_SUPLA_LOG_WRAPPER_H_
Generated by
1.17.0