-
Notifications
You must be signed in to change notification settings - Fork 28
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
21 changed files
with
177 additions
and
132 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
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
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,57 @@ | ||
|
||
#include "Precomp.h" | ||
#include "Logger.h" | ||
#include "VM/Frame.h" | ||
|
||
void LogMessage(const std::string& message) | ||
{ | ||
Logger::Get()->LogMessage(message); | ||
} | ||
|
||
void LogUnimplemented(const std::string& message) | ||
{ | ||
Logger::Get()->LogUnimplemented(message); | ||
} | ||
|
||
void Logger::LogMessage(const std::string& message) | ||
{ | ||
if (!Frame::Callstack.empty() && Frame::Callstack.back()->Func) | ||
{ | ||
UStruct* func = Frame::Callstack.back()->Func; | ||
std::string name; | ||
for (UStruct* s = func; s != nullptr; s = s->StructParent) | ||
{ | ||
if (name.empty()) | ||
name = s->Name.ToString(); | ||
else | ||
name = s->Name.ToString() + "." + name; | ||
} | ||
|
||
LogMessageLine line; | ||
line.Time = time; | ||
line.Source = name; | ||
line.Text = message; | ||
Log.push_back(std::move(line)); | ||
} | ||
else | ||
{ | ||
LogMessageLine line; | ||
line.Time = time; | ||
line.Text = message; | ||
Log.push_back(std::move(line)); | ||
} | ||
|
||
if (printLogDebugger) | ||
printLogDebugger(Log.back()); | ||
} | ||
|
||
void Logger::LogUnimplemented(const std::string& message) | ||
{ | ||
LogMessage("Unimplemented: " + message); | ||
} | ||
|
||
Logger* Logger::Get() | ||
{ | ||
static Logger logger; | ||
return &logger; | ||
} |
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,36 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
#include <list> | ||
#include <functional> | ||
|
||
void LogMessage(const std::string& message); | ||
void LogUnimplemented(const std::string& message); | ||
|
||
struct LogMessageLine | ||
{ | ||
float Time; | ||
std::string Source; | ||
std::string Text; | ||
}; | ||
|
||
class Logger | ||
{ | ||
public: | ||
static Logger* Get(); | ||
|
||
void LogMessage(const std::string& message); | ||
void LogUnimplemented(const std::string& message); | ||
void SetTimeSeconds(float value) { time = value; } | ||
void SetCallback(std::function<void(const LogMessageLine& line)> cb) { printLogDebugger = std::move(cb); } | ||
const std::list<LogMessageLine>& GetLog() const { return Log; } | ||
|
||
private: | ||
float time = 0.0f; | ||
std::list<LogMessageLine> Log; | ||
std::function<void(const LogMessageLine& line)> printLogDebugger; | ||
|
||
Logger() = default; | ||
Logger(const Logger&) = delete; | ||
Logger& operator=(const Logger&) = delete; | ||
}; |
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
Oops, something went wrong.