Complete restructuring and addition of core Logging system and dhcp module
This commit is contained in:
1 parent
8fa965823a
commit
7fa4d1fc58
49 files changed
+3627
-193
No files matched your search
@@ -0,0 +1,81 @@
|
||||
#include "Logger.hpp"
|
||||
#include <iostream>
|
||||
#include <ctime>
|
||||
|
||||
namespace Plains {
|
||||
namespace Core {
|
||||
|
||||
using std::cout;
|
||||
using std::cerr;
|
||||
using std::endl;
|
||||
|
||||
//static string getTimeStamp() { return ctime ( time ( 0 ) ); }
|
||||
|
||||
Logger::Logger(enum Level logLevel, EventBus& eventBus) :
|
||||
logLevel(logLevel),
|
||||
eventBus(eventBus)
|
||||
{
|
||||
logFile = ofstream("plains.log");
|
||||
|
||||
if (!logFile) {
|
||||
cerr << "Unable to open Logfile" << endl;
|
||||
//logFile = cout.fstream;
|
||||
}
|
||||
else {
|
||||
cout << "Log file opened" << endl;
|
||||
//oldStdOut = cout.rdbuf();
|
||||
//cout.rdbuf(logFile.rdbuf());
|
||||
}
|
||||
}
|
||||
|
||||
Logger::~Logger() {
|
||||
logFile.close();
|
||||
}
|
||||
|
||||
void Logger::setLogLevel(Level level) {
|
||||
}
|
||||
|
||||
void Logger::log(Level lvl, const string& msg) { log ( lvl, msg.c_str() ); }
|
||||
|
||||
void Logger::log(Level lvl, const char* msg) {
|
||||
switch ( lvl ) {
|
||||
case DEBUG: debug (msg); break;
|
||||
case INFO: info (msg); break;
|
||||
case WARN: warn (msg); break;
|
||||
case FATAL: fatal (msg); break;
|
||||
}
|
||||
}
|
||||
|
||||
void Logger::debug ( const string& msg ) {
|
||||
logFile << "DATESTAMP [DEBUG] " << msg << endl;
|
||||
}
|
||||
|
||||
void Logger::debug ( const char* msg ) {
|
||||
logFile << "DATESTAMP [DEBUG] " << msg << endl;
|
||||
}
|
||||
|
||||
void Logger::info ( const string& msg ) {
|
||||
if ( logLevel >= INFO ) logFile << "DATESTAMP [INFO] " << msg << endl;
|
||||
}
|
||||
|
||||
void Logger::info ( const char* msg ) {
|
||||
if ( logLevel >= INFO ) logFile << "DATESTAMP [INFO] " << msg << endl;
|
||||
}
|
||||
|
||||
void Logger::warn ( const string& msg ) {
|
||||
if ( logLevel >= WARN ) logFile << "DATESTAMP [WARN] " << msg << endl;
|
||||
}
|
||||
|
||||
void Logger::warn ( const char* msg ) {
|
||||
if ( logLevel >= WARN ) logFile << "DATESTAMP [WARN] " << msg << endl;
|
||||
}
|
||||
|
||||
void Logger::fatal ( const string& msg ) {
|
||||
if ( logLevel == FATAL ) logFile << "DATESTAMP [FATAL] " << msg << endl;
|
||||
}
|
||||
|
||||
void Logger::fatal ( const char* msg ) {
|
||||
if ( logLevel == FATAL ) logFile << "DATESTAMP [FATAL] " << msg << endl;
|
||||
}
|
||||
|
||||
}}
|
||||
Reference in new issue
Block a user