FUCK YOU C++2

This commit is contained in:
2024-08-14 14:44:33 -04:00
parent b69ba9650b
commit 7aa30a4966
2 changed files with 26 additions and 15 deletions

View File

@@ -1,13 +1,14 @@
#pragma once
#include <mcolor.h>
#include <token.hpp>
#include "token.hpp"
#include "Color4.hpp"
#include "Colors.hpp"
#include <source_location>
#include <map>
#include <jlog/token.hpp>
#include <Event.h>
#include "formatter.hpp"
namespace jlog
{
@@ -16,13 +17,14 @@ namespace jlog
class LogEntry {
public:
//LogEntry(Color4 context_color, const std::string &context, const std::string &message, const std::source_location &trace, const jlog::Timestamp &timestamp) {
LogEntry()
context_color = Colors::White;
context = "FUCK";
message = "YOU";
trace = std::source_location::current();
timestamp = Timestamp();
};
//LogEntry()
// context_color = Colors::White;
// context = "FUCK";
// message = "YOU";
// trace = std::source_location::current();
// timestamp = Timestamp();
//};
LogEntry(Color4 cc, const std::string c, const std::string msg, const std::source_location t, const Timestamp ts);
public:
Color4 ContextColor() { return context_color; }
std::string Context() { return context; }
@@ -68,7 +70,7 @@ namespace jlog
Color4 GetColorCode();
public:
std::string Context();
void SetTraceback(bool enabled);
void SetTraceback(bool b);
/**/
protected:
bool enabled = true;

View File

@@ -20,6 +20,14 @@ namespace jlog
};
*/
LogEntry::LogEntry(Color4 cc, const std::string c, const std::string msg, const std::source_location t, const Timestamp ts) {
this->context_color = cc;
this->context = c;
this->message = msg;
this->trace = t;
this->timestamp = ts;
};
std::vector<token> LogEntry::Tokenize() {
std::vector<token> tokens;
@@ -32,17 +40,18 @@ namespace jlog
timestamp.Hour().count(),
timestamp.Minute().count(),
timestamp.Second().count(),
timestamp.Millisecond().count())}};)
timestamp.Millisecond().count())});
tokens.push_back({.colorCode = context_color, .content = context});
if (IncludeTrace)
tokens.push_back({.content = std::format("{}:{}", trace.function_name(), trace.file_name(), trace.line())});
tokens.push_back({.content = message});
tokens.push_back({.content = message, .delimiter = ""});
//tokens.push_back(contextToken);
//tokens.push_back(messageToken);
return tokens;
}
Logger::Logger(const std::string& context, const Color4& color) {
@@ -54,8 +63,8 @@ namespace jlog
if (!enabled)
return;
LogEntry logentry = {colorcode, context, location, Timestamp()};
logentry.IncludeTrace = trace;
LogEntry logentry = {colorcode, context, message, location, Timestamp()};
logentry.IncludeTrace = this->trace;
logentry.IncludeTimestamp = true;
//std::vector<jlog::token> fmt;
@@ -102,8 +111,8 @@ namespace jlog
Log(message, location);
}
void Logger::SetTraceback(bool enabled) {
trace = enabled;
void Logger::SetTraceback(bool b) {
trace = b;
}
void Logger::Enable() { SetEnabled(true);}