-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArduinoLogger.h
More file actions
36 lines (26 loc) · 880 Bytes
/
Copy pathArduinoLogger.h
File metadata and controls
36 lines (26 loc) · 880 Bytes
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
#ifndef ARDUINO_LOGGER_H
#define ARDUINO_LOGGER_H
#ifndef LOGGER_BUFFER_SIZE
#define LOGGER_BUFFER_SIZE 128
#endif
#include <Arduino.h>
enum LogLevel { LOG_LEVEL_DEBUG, LOG_LEVEL_INFO, LOG_LEVEL_WARN, LOG_LEVEL_ERROR, LOG_LEVEL_NONE };
class ArduinoLogger {
public:
ArduinoLogger(Stream &stream = Serial, LogLevel level = LOG_LEVEL_INFO);
void setLogLevel(LogLevel level);
void debug(const char *msg);
void info(const char *msg);
void warn(const char *msg);
void error(const char *msg);
void debugf(const char *format, ...);
void infof(const char *format, ...);
void warnf(const char *format, ...);
void errorf(const char *format, ...);
private:
Stream &_stream;
LogLevel _level;
void _log(LogLevel msgLevel, const char *prefix, const char *msg);
void _logf(LogLevel msgLevel, const char *prefix, const char *format, va_list args);
};
#endif