Files
jlog/include/jlog/logger.hpp
2024-08-13 13:40:20 -04:00

43 lines
1.4 KiB
C++

#pragma once
#include <mcolor.h>
#include <source_location>
#include <map>
namespace jlog
{
using namespace mcolor;
///
class Logger {
public:
explicit Logger(const std::string& context, const AnsiColor& color = AnsiColor::FG_DEFAULT);
public:
void operator () (const std::string& message, const std::source_location& location = std::source_location::current());
virtual void Log(const std::string &message, const std::source_location& location = std::source_location::current());
//virtual void LogTrace(const std::vector<token> tokens);
//virtual void LogTrace(const std::string& context, const std::string &message);
//virtual void LogTrace(const std::string &message, const std::source_location& location = std::source_location::current());
public:
void SetEnabled(bool state);
void Enable();
void Disable();
bool Enabled();
void LogFile(const std::string& f);
std::string LogFile();
// no cc no bullshit
void ColorCode(AnsiColor cc = AnsiColor::FG_DEFAULT);
AnsiColor ColorCode();
public:
std::string Context();
void SetTraceback(bool enabled);
/**/
protected:
bool enabled = true;
std::string logfile = "latest.log";
AnsiColor colorcode = AnsiColor::FG_DEFAULT;
std::string context;
bool trace = true;
};
}