supla-device
Loading...
Searching...
No Matches
log.h
1// SPDX-FileCopyrightText: AC SOFTWARE SP. Z O.O.
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#ifndef suplalog_H_
5#define suplalog_H_
6
7#if defined(ESP8266)
8#include <mem.h>
9#define LOG_ICACHE_FLASH ICACHE_FLASH_ATTR
10#endif
11
12#if defined(ARDUINO)
13#undef LOG_ICACHE_FLASH
14#endif /*defined(ARDUINO)*/
15
16#ifndef LOG_ICACHE_FLASH
17#define LOG_ICACHE_FLASH
18#endif /*LOG_ICACHE_FLASH*/
19
20#if defined(ESP8266) || defined(__AVR__) || defined(_WIN32) || \
21 defined(ESP32) || defined(SUPLA_DEVICE) || defined(SUPLA_TEST)
22
23#define LOG_EMERG 0
24#define LOG_ALERT 1
25#define LOG_CRIT 2
26#define LOG_ERR 3
27#define LOG_WARNING 4
28#define LOG_NOTICE 5
29#define LOG_INFO 6
30#define LOG_DEBUG 7
31#define LOG_VERBOSE 8
32
33#else
34
35#include <syslog.h>
36
37#endif // defined(ESP8266) || defined(__AVR__)
38 // || defined(_WIN32) || defined(ESP32) || defined(SUPLA_DEVICE)
39
40#ifdef __cplusplus
41extern "C" {
42#endif
43
44#ifdef __LOG_CALLBACK
45typedef int (*_supla_log_callback)(int __pri, const char *message);
46
47void LOG_ICACHE_FLASH supla_log_set_callback(_supla_log_callback callback);
48#endif /*__LOG_CALLBACK*/
49
50void LOG_ICACHE_FLASH supla_log_set_level(int level);
51int LOG_ICACHE_FLASH supla_log_get_level(void);
52char LOG_ICACHE_FLASH supla_log_is_enabled(int level);
53void LOG_ICACHE_FLASH supla_log(int __pri, const char *__fmt, ...);
54void LOG_ICACHE_FLASH supla_write_state_file(const char *file, int __pri,
55 const char *__fmt, ...);
56
57#ifdef __cplusplus
58}
59#endif /*__cplusplus*/
60
61#endif /* suplalog_H_ */