Compare commits
3 Commits
Prerelease
...
main
Author | SHA1 | Date | |
---|---|---|---|
6836cab537 | |||
e618fd9b31 | |||
884f23f79e |
@@ -28,7 +28,7 @@ CPMAddPackage(
|
||||
|
||||
CPMAddPackage(
|
||||
NAME mcolor
|
||||
URL https://git.redacted.cc/maxine/mcolor/archive/Prerelease-5.zip
|
||||
URL https://git.redacted.cc/maxine/mcolor/archive/Release-1.zip
|
||||
)
|
||||
|
||||
if (UNIX)
|
||||
|
@@ -1,18 +1,18 @@
|
||||
#pragma once
|
||||
#include "fstream"
|
||||
#include "iostream"
|
||||
#include "source_location"
|
||||
#include "Token.hpp"
|
||||
#include "Timestamp.hpp"
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <source_location>
|
||||
#include <jlog/Token.hpp>
|
||||
#include <jlog/Timestamp.hpp>
|
||||
#include <Event.h>
|
||||
|
||||
namespace jlog {
|
||||
class Logger {
|
||||
public:
|
||||
|
||||
Logger(std::ostream &stream = std::cout) : os{stream} {};
|
||||
public:
|
||||
void
|
||||
operator()(const std::string &message, const std::source_location &location = std::source_location::current(),
|
||||
void operator()(const std::string &message, const std::source_location &location = std::source_location::current(),
|
||||
const Timestamp &ts = Timestamp()) {
|
||||
if (Enable)
|
||||
Log(message, location, ts);
|
||||
@@ -47,10 +47,7 @@ namespace jlog {
|
||||
const Timestamp &ts = Timestamp()) {
|
||||
if (!Enable)
|
||||
return;
|
||||
// Disable color on Windows. I've been trying my best to keep this macro hidden from the user. - maxine
|
||||
#ifdef WIN32
|
||||
IncludeColor = false;
|
||||
#endif
|
||||
|
||||
if (IncludeTimestamp) {
|
||||
Timestamp ts;
|
||||
os << token{std::format(
|
||||
@@ -127,6 +124,7 @@ namespace jlog {
|
||||
|
||||
class CompoundLogger : protected ConsoleLogger, protected FileLogger {
|
||||
public:
|
||||
Event<std::string, Color4> OnLog;
|
||||
explicit CompoundLogger(const std::string &context, std::ofstream &file) : ConsoleLogger(context),
|
||||
FileLogger(context, file) {};
|
||||
public:
|
||||
@@ -137,6 +135,7 @@ namespace jlog {
|
||||
virtual void
|
||||
Log(const std::string &message, const std::source_location &location = std::source_location::current(),
|
||||
const Timestamp &ts = Timestamp()) {
|
||||
OnLog.Invoke(message, messageColor);
|
||||
ConsoleLogger::Log(message, location, ts);
|
||||
FileLogger::Log(message, location, ts);
|
||||
}
|
||||
|
@@ -7,13 +7,13 @@ namespace jlog {
|
||||
public:
|
||||
Timestamp();
|
||||
public:
|
||||
std::chrono::year Year() {return y;};
|
||||
std::chrono::month Month() {return m;};
|
||||
std::chrono::day Day() {return d;}
|
||||
std::chrono::duration<long, std::ratio<3600>> Hour() {return h;};
|
||||
std::chrono::duration<long, std::ratio<60>> Minute() {return M;};
|
||||
std::chrono::duration<long> Second() {return s;};
|
||||
std::chrono::duration<long, std::ratio<1, 1000>> Millisecond() {return ms;};
|
||||
[[nodiscard]] std::chrono::year Year() const {return y;};
|
||||
[[nodiscard]] std::chrono::month Month() const {return m;};
|
||||
[[nodiscard]] std::chrono::day Day() const {return d;}
|
||||
[[nodiscard]] std::chrono::duration<long, std::ratio<3600>> Hour() const {return h;};
|
||||
[[nodiscard]] std::chrono::duration<long, std::ratio<60>> Minute() const {return M;};
|
||||
[[nodiscard]] std::chrono::duration<long> Second() const {return s;};
|
||||
[[nodiscard]] std::chrono::duration<long, std::ratio<1, 1000>> Millisecond() const {return ms;};
|
||||
private:
|
||||
std::chrono::year y;
|
||||
std::chrono::month m;
|
||||
|
Reference in New Issue
Block a user