supla-device
Loading...
Searching...
No Matches
log.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 suplalog_H_
20#define suplalog_H_
21
22#if defined(ESP8266)
23#include <mem.h>
24#define LOG_ICACHE_FLASH ICACHE_FLASH_ATTR
25#endif
26
27#if defined(ARDUINO)
28#undef LOG_ICACHE_FLASH
29#endif /*defined(ARDUINO)*/
30
31#ifndef LOG_ICACHE_FLASH
32#define LOG_ICACHE_FLASH
33#endif /*LOG_ICACHE_FLASH*/
34
35#if defined(ESP8266) || defined(__AVR__) || defined(_WIN32) || \
36 defined(ESP32) || defined(SUPLA_DEVICE) || defined(SUPLA_TEST)
37
38#define LOG_EMERG 0
39#define LOG_ALERT 1
40#define LOG_CRIT 2
41#define LOG_ERR 3
42#define LOG_WARNING 4
43#define LOG_NOTICE 5
44#define LOG_INFO 6
45#define LOG_DEBUG 7
46#define LOG_VERBOSE 8
47
48#else
49
50#include <syslog.h>
51
52#endif // defined(ESP8266) || defined(__AVR__)
53 // || defined(_WIN32) || defined(ESP32) || defined(SUPLA_DEVICE)
54
55#ifdef __cplusplus
56extern "C" {
57#endif
58
59#ifdef __LOG_CALLBACK
60typedef int (*_supla_log_callback)(int __pri, const char *message);
61
62void LOG_ICACHE_FLASH supla_log_set_callback(_supla_log_callback callback);
63#endif /*__LOG_CALLBACK*/
64
65void LOG_ICACHE_FLASH supla_log(int __pri, const char *__fmt, ...);
66void LOG_ICACHE_FLASH supla_write_state_file(const char *file, int __pri,
67 const char *__fmt, ...);
68
69#ifdef __cplusplus
70}
71#endif /*__cplusplus*/
72
73#endif /* suplalog_H_ */