HomeWaterLeaksDetection
Logger.cpp
Go to the documentation of this file.
1 #include "Logger.h"
2 
4 
6  if (instance == NULL) instance = new Logger;
7  return instance;
8 }
9 
11  logs.push_back(log);
12 }
13 
15  if (timePeriod.isActive()) {
16  Serial.println();
17  for (const auto log : logs) {
18  Serial.print("[");
19  Serial.print(FORMAT_TIME(millis()));
20  Serial.print("]");
21  Serial.print(log->getLogID());
22  Serial.println(log->getLogDescription());
23  }
24  }
25 };
FORMAT_TIME
#define FORMAT_TIME(time)
Converts a time in milliseconds into a formatted string.
Definition: DateTime.h:141
Logger::update
void update() override
Updates the class.
Definition: Logger.cpp:14
Logger::getInstance
static Logger * getInstance()
Returns the instance of the class.
Definition: Logger.cpp:5
Logger::instance
static Logger * instance
the instance of the class
Definition: Logger.h:24
Logger::timePeriod
TimePeriod timePeriod
time period for recognizing when the log should be printed out
Definition: Logger.h:26
TimePeriod::isActive
int isActive()
Returns information if the period of time has passed.
Definition: TimePeriod.cpp:7
Logger.h
ILoggable
Definition: ILoggable.h:13
Logger::addEntity
void addEntity(ILoggable *log)
Adds another class to the logging system.
Definition: Logger.cpp:10
Logger::Logger
Logger()
Constructor of the class.
Definition: Logger.h:31
Logger
Definition: Logger.h:20
Logger::logs
std::vector< ILoggable * > logs
collection of classes that are registered in the logging system
Definition: Logger.h:25