This commit is contained in:
Sven Luethi committed 2021-03-27 14:18:53 +01:00
1 parent 062f9c8c69
commit 2fedb29014
3 files changed
+13 -5

No files matched your search

-3
View File
@@ -17,7 +17,6 @@ EventBus::~EventBus() {
}
Event& EventBus::registerEvent(const string& eventID) {
bool eventFound = false;
for ( const auto event : _events ) {
if (event->getID() == eventID) {
_logger.debug << "Event '" << eventID << "' found" << Logger::commit;
@@ -25,12 +24,10 @@ Event& EventBus::registerEvent(const string& eventID) {
}
}
//If event with that id does not exist, create it:
if (!eventFound) {
_logger.debug << "Registering new Event '" << eventID << "'" << Logger::commit;
Event* event = new Event(eventID);
_events.push_back(event);
return *event;
}
}
void EventBus::run() {
+7 -2
View File
@@ -12,8 +12,8 @@ using std::endl;
Logger::Logger(enum Level logLevel) :
_logLevel(logLevel),
debug(DEBUG, *this),
info(INFO, *this),
warn(WARN, *this),
info (INFO, *this),
warn (WARN, *this),
fatal(FATAL, *this)
{
_output = new ofstream("plains.log", std::ios_base::app);
@@ -106,6 +106,7 @@ Logger::Sink& Logger::Sink::operator<<(const string& msg) {
if ( _level >= _parent._logLevel ) {
prefixLine();
*_parent._output << msg;
cout << msg;
}
return *this;
}
@@ -114,6 +115,7 @@ Logger::Sink& Logger::Sink::operator<<(const char* msg) {
if ( _level >= _parent._logLevel ) {
prefixLine();
*_parent._output << msg;
cout << msg;
}
return *this;
}
@@ -122,6 +124,7 @@ Logger::Sink& Logger::Sink::operator<<(const int msg) {
if ( _level >= _parent._logLevel ) {
prefixLine();
*_parent._output << msg;
cout << msg;
}
return *this;
}
@@ -130,6 +133,7 @@ Logger::Sink& Logger::Sink::operator<<(const long msg) {
if ( _level >= _parent._logLevel ) {
prefixLine();
*_parent._output << msg;
cout << msg;
}
return *this;
}
@@ -138,6 +142,7 @@ Logger::Sink& Logger::Sink::operator<<(const unsigned long msg) {
if ( _level >= _parent._logLevel ) {
prefixLine();
*_parent._output << msg;
cout << msg;
}
return *this;
}
+6
View File
@@ -12,6 +12,12 @@ using std::string;
int main(int args, char **argv) {
Logger logger(Logger::DEBUG);
//logger.debug.ln ("Debug message");
//logger.info.ln ("Info message");
//logger.warn.ln ("Warning message");
//logger.fatal.ln ("Fatal message");
logger.info.ln ("Starting PlaiNS...");
try