supla-device
Loading...
Searching...
No Matches
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
27extern "C" char supla_log_string(char **buffer, int *size, va_list va,
28 const char *__fmt);
29extern "C" void supla_vlog(int __pri, const char *message);
30
31
32#ifdef ARDUINO
33#include <Arduino.h>
34
35class __FlashStringHelper;
36
37void supla_logf(int __pri, const __FlashStringHelper *__fmt, ...);
38
39#else
40
41#ifndef F
42#define F(argument_F) (argument_F)
43#endif
44
45#define supla_logf supla_log
46#endif
47
48// #define SUPLA_DISABLE_LOGS
49
50#ifdef SUPLA_DISABLE_LOGS
51// uncomment below lines to disable certain logs
52#define SUPLA_LOG_VERBOSE(arg_format, ...) {};
53#define SUPLA_LOG_DEBUG(arg_format, ...) {};
54#define SUPLA_LOG_INFO(arg_format, ...) {};
55#define SUPLA_LOG_WARNING(arg_format, ...) {};
56#define SUPLA_LOG_ERROR(arg_format, ...) {};
57#endif
58
59
60#ifndef SUPLA_LOG_VERBOSE
61#define SUPLA_LOG_VERBOSE(arg_format, ...) \
62 supla_logf(LOG_VERBOSE, F(arg_format) , ## __VA_ARGS__)
63#endif
64
65#ifndef SUPLA_LOG_DEBUG
66#define SUPLA_LOG_DEBUG(arg_format, ...) \
67 supla_logf(LOG_DEBUG, F(arg_format) , ## __VA_ARGS__)
68#endif
69
70#ifndef SUPLA_LOG_INFO
71#define SUPLA_LOG_INFO(arg_format, ...) \
72 supla_logf(LOG_INFO, F(arg_format) , ## __VA_ARGS__)
73#endif
74
75#ifndef SUPLA_LOG_WARNING
76#define SUPLA_LOG_WARNING(arg_format, ...) \
77 supla_logf(LOG_WARNING, F(arg_format) , ## __VA_ARGS__)
78#endif
79
80#ifndef SUPLA_LOG_ERROR
81#define SUPLA_LOG_ERROR(arg_format, ...) \
82 supla_logf(LOG_ERR, F(arg_format) , ## __VA_ARGS__)
83#endif
84
85#endif // SRC_SUPLA_LOG_WRAPPER_H_