This commit is contained in:
Suraxius committed 2021-01-09 01:37:05 +01:00
1 parent 0dfda6f481
commit 9fac304771
9 files changed
+116 -51

No files matched your search

+10 -7
View File
@@ -3,35 +3,39 @@
#include <string>
#include <fstream>
#include <ostream>
#include "EventBus.hpp"
namespace Plains {
namespace Core {
using std::string;
using std::ofstream;
using std::ostream;
using std::streambuf;
//using std::ostream;
//using std::streambuf;
class Logger {
public:
enum Level { DEBUG, INFO, WARN, FATAL };
Logger(Level logLevel, EventBus& eventBus);
Logger(Level logLevel);
~Logger();
void setLogLevel(Level level);
void log(Level lvl, const char* msg);
void log(Level lvl, const string& msg);
static const char commit = 0;
class Sink {
private:
bool lineIsPrefixed;
Logger& parent;
const Logger::Level level;
void prefixLine(bool resetToFalse = false);
public:
Sink(const Level level, Logger& parent);
void ln (const string& msg);
void ln (const char* msg);
Sink& operator<<(const char character);
Sink& operator<<(const string& msg);
Sink& operator<<(const char* msg);
Sink& operator<<(const unsigned long msg);
};
Sink debug;
@@ -40,10 +44,9 @@ class Logger {
Sink fatal;
private:
EventBus& eventBus;
enum Level logLevel;
ofstream logFile;
streambuf* oldStdOut;
ofstream* output;
static string genTimeStamp();
};