EEPROM-Storage Library
The EEPROM Storage library provides the ability to access variables stored in EEPROM just as if they were stored in RAM.
 
Loading...
Searching...
No Matches
EEPROM-Debug.h
Go to the documentation of this file.
1/*
2 This file is part of EEPROMDebug. Modified by
3 Daniel M Porrey to work on the Particle platform.
4
5 Copyright 2019 ARDUINO SA (http://www.arduino.cc/)
6
7 This software is released under the GNU General Public License version 3,
8 which covers the main part of arduino-cli.
9 The terms of this license can be found at:
10 https://www.gnu.org/licenses/gpl-3.0.en.html
11
12 You can be released from the requirements of the above licenses by purchasing
13 a commercial license. Buying such a license is mandatory if you want to modify or
14 otherwise use the software for commercial activities involving the Arduino
15 software without disclosing the source code of your own applications. To purchase
16 a commercial license, send an email to license@arduino.cc.
17*/
18
19#ifndef EEPROM_DEBUG_H
20#define EEPROM_DEBUG_H
21
22/******************************************************************************
23 INCLUDE
24 ******************************************************************************/
25#if defined(ARDUINO) && ARDUINO >= 100
26 #include <Arduino.h>
27 #include <stdarg.h>
28#elif defined(PARTICLE)
29 #include <Particle.h>
30#endif
31
32/******************************************************************************
33 CONSTANTS
34 ******************************************************************************/
35
36static int const DBG_NONE = -1;
37static int const DBG_ERROR = 0;
38static int const DBG_WARNING = 1;
39static int const DBG_INFO = 2;
40static int const DBG_DEBUG = 3;
41static int const DBG_VERBOSE = 4;
42
43void setDebugMessageLevel(int const debug_level);
45
46/******************************************************************************
47 CLASS DECLARATION
48 ******************************************************************************/
49
51
52 public:
53
55
56 void setDebugLevel(int const debug_level);
57 int getDebugLevel() const;
58
59 void setDebugOutputStream(Stream * stream);
60
61 void timestampOn();
62 void timestampOff();
63
64 void newlineOn();
65 void newlineOff();
66
67 void debugLabelOn();
68 void debugLabelOff();
69
70 void formatTimestampOn();
71 void formatTimestampOff();
72
73 void print(int const debug_level, const char * fmt, ...);
74 void print(int const debug_level, const __FlashStringHelper * fmt, ...);
75
76
77 private:
78
79 bool _timestamp_on;
80 bool _newline_on;
81 bool _print_debug_label;
82 bool _format_timestamp_on;
83 int _debug_level;
84 Stream * _debug_output_stream;
85
86 void vPrint(char const * fmt, va_list args);
87 void printTimestamp();
88 void printDebugLabel(int const debug_level);
89 bool shouldPrint(int const debug_level) const;
90
91};
92
93/******************************************************************************
94 EXTERN
95 ******************************************************************************/
96
97extern EEPROMDebug Debug;
98
99/**************************************************************************************
100 * DEFINE
101 **************************************************************************************/
102
103#ifndef DEBUG_ERROR
104# define DEBUG_ERROR(fmt, ...) Debug.print(DBG_ERROR, fmt, ## __VA_ARGS__)
105#endif
106
107#ifndef DEBUG_WARNING
108# define DEBUG_WARNING(fmt, ...) Debug.print(DBG_WARNING, fmt, ## __VA_ARGS__)
109#endif
110
111#ifndef DEBUG_INFO
112# define DEBUG_INFO(fmt, ...) Debug.print(DBG_INFO, fmt, ## __VA_ARGS__)
113#endif
114
115#ifndef DEBUG_DEBUG
116# define DEBUG_DEBUG(fmt, ...) Debug.print(DBG_DEBUG, fmt, ## __VA_ARGS__)
117#endif
118
119#ifndef DEBUG_VERBOSE
120# define DEBUG_VERBOSE(fmt, ...) Debug.print(DBG_VERBOSE, fmt, ## __VA_ARGS__)
121#endif
122
123#endif
EEPROMDebug Debug
int getDebugMessageLevel()
void setDebugMessageLevel(int const debug_level)
void formatTimestampOn()
void formatTimestampOff()
void setDebugLevel(int const debug_level)
void setDebugOutputStream(Stream *stream)
void print(int const debug_level, const char *fmt,...)
void debugLabelOn()
void newlineOff()
void debugLabelOff()
void timestampOn()
void timestampOff()
int getDebugLevel() const