Files
IoTManager/include/Utils/PrintMessage.h

33 lines
674 B
C
Raw Normal View History

2020-06-22 03:11:02 +03:00
#pragma once
#include "Arduino.h"
#include "CommonTypes.h"
#include "Utils\StringUtils.h"
#include "Utils\TimeUtils.h"
#include "Errors.h"
#define pm PrintMessage(MODULE)
class PrintMessage {
public:
PrintMessage(const char* module) {
_module = module;
}
2020-06-25 09:21:42 +03:00
void error(const String& str) {
2020-06-22 03:11:02 +03:00
print(EL_ERROR, str);
}
2020-06-25 09:21:42 +03:00
void info(const String& str) {
2020-06-22 03:11:02 +03:00
print(EL_INFO, str);
}
private:
void print(const ErrorLevel_t level, const String& str) {
2020-06-27 01:21:58 +03:00
Serial.printf("%s [%s] [%s] %s\n", prettyMillis(millis()).c_str(), getErrorLevelStr(level).c_str(), _module, str.c_str());
2020-06-22 03:11:02 +03:00
}
private:
const char* _module;
};