EX-Display
EX-Display
Loading...
Searching...
No Matches
/home/runner/work/EX-Display/EX-Display/Logger.h
Go to the documentation of this file.
1/*
2 * © 2024 Peter Cole
3 *
4 * This is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * It 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 code. If not, see <https://www.gnu.org/licenses/>.
16 */
17
18#ifndef LOGGER_H
19#define LOGGER_H
20
21#include <Arduino.h>
22
25#define LOG(level, ...) \
26 if (_logger) \
27 _logger->log(level, __VA_ARGS__)
28
31
35class Logger {
36public:
39 Logger(Stream *outputStream);
40
43 void setLogLevel(LogLevel logLevel);
44
48
52 void log(LogLevel logLevel, const char *format, ...);
53
54private:
57};
58
59#endif // LOGGER_H
LogLevel
Define valid log levels in ascending order.
Definition Logger.h:30
@ LOG_ERROR
Definition Logger.h:30
@ LOG_INFO
Definition Logger.h:30
@ LOG_MESSAGE
Definition Logger.h:30
@ LOG_NONE
Definition Logger.h:30
@ LOG_DEBUG
Definition Logger.h:30
@ LOG_WARN
Definition Logger.h:30
Class to enable simple logging to a Stream object with different log levels This enables embedding pe...
Definition Logger.h:35
Stream * _outputStream
Definition Logger.h:55
LogLevel getLogLevel()
Get the current log level.
Definition Logger.cpp:24
void setLogLevel(LogLevel logLevel)
Set the log level.
Definition Logger.cpp:22
LogLevel _currentLevel
Definition Logger.h:56
void log(LogLevel logLevel, const char *format,...)
Log a message for the specified log level.
Definition Logger.cpp:26
Class to mock the basic Stream function equivalent of the Arduino framework.
Definition Stream.h:25