-
Notifications
You must be signed in to change notification settings - Fork 7
/
Logger.h
58 lines (46 loc) · 1.83 KB
/
Logger.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*************************************************************************
*
* This file is part of the Remoterelay Arduino sketch.
* Copyleft 2017 Nicolas Agius <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* ***********************************************************************/
#ifndef LOGGER_H
#define LOGGER_H
#include "Arduino.h"
#define BUF_LEN 180 // Max length of each line of log
#define RINGLOG_SIZE 100 // Max number of line in the ring log
/**
* This class provide a logging facility to print log messages on the
* serial output and store the last ones in a ring buffer for further access.
*/
class Logger
{
private:
char ringlog[RINGLOG_SIZE][BUF_LEN];
int index;
bool enableDebug;
bool enableSerial;
public:
Logger();
void info(const char *, ...); // Print and store message log
void debug(const char *, ...); // Print and store message log if debug mode is enabled
void setDebug(bool); // Enable debug mode
void setSerial(bool); // Enable log output on serial port
String getLog(void); // Return the current log
private:
void log(const char *, va_list);
};
#endif // LOGGER_H