Overload Logger started

This commit is contained in:
Ben
2018-12-01 11:29:06 +00:00
parent 23a2382d3a
commit e83c3a635b
7 changed files with 30 additions and 10 deletions

View File

@@ -50,6 +50,9 @@
"typeindex": "cpp",
"typeinfo": "cpp",
"utility": "cpp",
"variant": "cpp"
"variant": "cpp",
"condition_variable": "cpp",
"mutex": "cpp",
"valarray": "cpp"
}
}

1
CMakeFiles/Progress/1 Normal file
View File

@@ -0,0 +1 @@
empty

View File

@@ -0,0 +1 @@
12

View File

@@ -9,7 +9,7 @@ x -> complete
**TODO**
[-] Comment the code
[ ] Overload operators in the logger and support for streams
[?] Overload operators in the logger and support for streams
[ ] Entity system
[ ] Entity manager
[ ] Ability to make entities and manage textures between them

View File

@@ -44,7 +44,7 @@ public:
static void resetColour() {
std::cout
<< "\033[" << CONSOLE_COLOUR_BG_DEFAULT << "m";
<< "\033[" << CONSOLE_COLOUR_BG_DEFAULT << "m"
<< "\033[" << CONSOLE_COLOUR_FG_DEFAULT << "m";
}

View File

@@ -10,17 +10,27 @@ public:
std::cout << getTime() << " " << obj << std::endl;
}
template<class T>
static void info(T obj) {
std::cout
<< getTime() << " [" << Colour::getColouredText(CONSOLE_COLOUR_FG_GREEN, "INFO")
<< "] " << obj << std::endl;
}
class Log {
public:
Log();
template<class T>
Log* operator<<(T obj) {
m_stream << obj;
return this;
}
~Log() {
std::string output = m_stream.str();
Logger::log(output);
}
private:
std::stringstream m_stream;
};
template<class T>
static void info(T obj) {
std::cout
<< getTime() << " [" << Colour::getColouredText(CONSOLE_COLOUR_FG_LIGHT_BLUE, "DEBUG")
<< getTime() << " [" << Colour::getColouredText(CONSOLE_COLOUR_FG_GREEN, "INFO")
<< "] " << obj << std::endl;
}

View File

@@ -1,7 +1,12 @@
#include "crumpet-engine/crumpet-engine.h"
#include "crumpet-engine/rect.h"
#include <logger.h>
int main(int argc, char** argv) {
Logger.Log() << "Okay, this is epic" << 1234;
Game game;
game.renderer.createWindow("Crumpet Engine", 600, 400, SCREEN_MODE_VSYNC);