My Project
Loading...
Searching...
No Matches
log4MC.h
Go to the documentation of this file.
1#pragma once
2
3#include <Arduino.h>
4#include <Syslog.h> // Syslog library.
5#include <WiFiUdp.h> // UDP library required for Syslog.
6
8
9#ifdef MC_DEBUG
10#define MC_LOG_DEBUG(...) log4MC::vlogf(LOG_DEBUG, __VA_ARGS__)
11#else
12#define MC_LOG_DEBUG(...)
13#endif
14
15#ifdef MC_INFO
16#define MC_LOG_INFO(...) log4MC::vlogf(LOG_INFO, __VA_ARGS__)
17#else
18#define MC_LOG_INFO(...)
19#endif
20
21class log4MC
22{
23 public:
24 // Setup the logger.
25 static void Setup(const char *hostName, MCLoggingConfiguration *config);
26 static void wifiIsConnected(bool connected);
27 static void vlogf(uint8_t level, const char *fmt, ...);
28 static void log(uint8_t level, const char *message);
29 static void debug(const char *message);
30 static void info(const char *message);
31 static void info(String message);
32 static void warn(const char *message);
33 static void error(const char *message);
34 static void fatal(const char *message);
35
36 private:
37 static void logMessage(uint8_t level, char *message);
38 static void setLogMask(uint8_t priMask);
39 static uint8_t getLogMask();
40
41 static MCLoggingConfiguration *_config;
42 static bool _connected;
43 static uint8_t _priMask;
44 static WiFiUDP _udpClient;
45 static Syslog syslog;
46 static unsigned int lineNo;
47};
@ connected
Definition MController.h:16
Definition log4MC.h:22
static void log(uint8_t level, const char *message)
Definition log4MC.cpp:85
static void warn(const char *message)
Definition log4MC.cpp:113
static void info(const char *message)
Definition log4MC.cpp:108
static void debug(const char *message)
Definition log4MC.cpp:103
static void fatal(const char *message)
Definition log4MC.cpp:123
static void error(const char *message)
Definition log4MC.cpp:118
static void vlogf(uint8_t level, const char *fmt,...)
Definition log4MC.cpp:60
static void Setup(const char *hostName, MCLoggingConfiguration *config)
Definition log4MC.cpp:3
static void wifiIsConnected(bool connected)
Definition log4MC.cpp:31
Definition MCLoggingConfiguration.h:6