-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
115 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
|
||
- Book 2 section 4 : texture mapping | ||
- Book 2 section 8 : instances | ||
- make buildchain crossplatform with CMake | ||
- test to replace RNG for grid sampling in antialiasing | ||
- centralize asset loading in a resource manager | ||
- find a good name for the project | ||
- have a format describing scenes instead of code description | ||
- add log system | ||
- add render queue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
|
||
#include "logger.hpp" | ||
|
||
#include <sstream> | ||
#include <chrono> | ||
#include <iostream> | ||
|
||
|
||
using namespace std; | ||
using namespace std::chrono; | ||
|
||
|
||
string Logger::GetCurrentTimeFormatted() | ||
{ | ||
auto now = std::chrono::system_clock::now(); | ||
return format("[{:%T}]", zoned_time{ current_zone(), floor<milliseconds>(now)}); | ||
} | ||
|
||
|
||
void Logger::Log(const std::string &log, const LogLevel& level) | ||
{ | ||
if(level < s_level){ | ||
return; | ||
} | ||
|
||
ostringstream string_builder; | ||
string_builder << GetCurrentTimeFormatted() << " "; | ||
string_builder << s_colored_name_lookup.at(level) << " "; | ||
string_builder << log << endl; | ||
|
||
const string& formatted_log = string_builder.str(); | ||
for(ostream* stream : s_outputs){ | ||
*stream << formatted_log; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
|
||
#pragma once | ||
|
||
#include <vector> | ||
#include <unordered_map> | ||
|
||
|
||
enum class LogLevel { | ||
DEBUG = 1, | ||
INFO = 2, | ||
WARNING = 3, | ||
ERROR = 4, | ||
FATAL = 5 | ||
}; | ||
|
||
|
||
class Logger { | ||
|
||
private: | ||
|
||
static inline std::vector<std::ostream*> s_outputs = { &std::cout }; | ||
static inline LogLevel s_level = LogLevel::DEBUG; | ||
|
||
static inline const std::unordered_map<LogLevel, std::string> s_colored_name_lookup | ||
{ | ||
{ LogLevel::DEBUG, "[\x1b[94mDEBUG\x1b[0m] " }, | ||
{ LogLevel::INFO, "[INFO] " }, | ||
{ LogLevel::WARNING, "[\x1b[93mWARNING\x1b[0m]" }, | ||
{ LogLevel::ERROR, "[\x1b[91mERROR\x1b[0m] " }, | ||
{ LogLevel::FATAL, "[\x1b[31mFATAL\x1b[0m] " } | ||
}; | ||
|
||
static void Log(const std::string& log, const LogLevel& level); | ||
static std::string GetCurrentTimeFormatted(); | ||
|
||
|
||
public: | ||
|
||
static void SetLogLevel(const LogLevel& level) { s_level = level; } | ||
static void AddOutput(std::ostream& stream) { s_outputs.push_back(&stream); } | ||
|
||
static void LogDebug(const std::string& log) { Log(log, LogLevel::DEBUG); } | ||
static void LogInfo(const std::string& log) { Log(log, LogLevel::INFO); } | ||
static void LogWarning(const std::string& log) { Log(log, LogLevel::WARNING); } | ||
static void LogError(const std::string& log) { Log(log, LogLevel::ERROR); } | ||
static void LogFatal(const std::string& log) { Log(log, LogLevel::FATAL); } | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters