Skip to content

Commit

Permalink
chore: change default param in formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
OEOTYAN committed Aug 28, 2024
1 parent 4d5b280 commit e80d1c1
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/ll/api/io/DefaultSink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ DefaultSink::Impl& DefaultSink::getImpl() {
}

DefaultSink::DefaultSink()
: Sink(makePolymorphic<PatternFormatter>("{tm:.3%T.} {lvl} {tit} {msg}", pl::pl_color_log, 0b0010)),
: Sink(makePolymorphic<PatternFormatter>("{tm:.3%T.} {lvl} {tit} {msg}", Formatter::supportColorLog(), 0b0010)),
impl(getImpl()) {}

DefaultSink::~DefaultSink() = default;
Expand Down
6 changes: 6 additions & 0 deletions src/ll/api/io/Formatter.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "ll/api/io/Formatter.h"
#include "pl/Config.h"

namespace ll::io {
bool Formatter::supportColorLog() { return (bool)pl::pl_color_log; }
} // namespace ll::io
3 changes: 3 additions & 0 deletions src/ll/api/io/Formatter.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#pragma once

#include "ll/api/io/LogMessage.h"
#include "ll/api/base/Macro.h"

namespace ll::io {
class Formatter {
public:
static LLNDAPI bool supportColorLog();

virtual ~Formatter() = default;

virtual void format(LogMessageView const& view, std::string& buffer) const noexcept = 0;
Expand Down
3 changes: 1 addition & 2 deletions src/ll/api/io/PatternFormatter.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include <array>
#include <bitset>

#include "ll/api/base/Macro.h"
#include "ll/api/io/Formatter.h"

#include "fmt/color.h"
Expand Down Expand Up @@ -51,7 +50,7 @@ class PatternFormatter : public Formatter {
}
};

PatternFormatter(std::string pattern, bool colored = true, std::bitset<4> const& bracketed = 0)
PatternFormatter(std::string pattern, bool colored = supportColorLog(), std::bitset<4> const& bracketed = 0)
: pattern(std::move(pattern)),
bracketed(bracketed),
colored(colored) {}
Expand Down
2 changes: 0 additions & 2 deletions src/ll/api/io/Sink.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#include "ll/api/io/Sink.h"

#include "pl/Config.h"

namespace ll::io {
Sink::~Sink() = default;
Sink::Sink(Polymorphic<Formatter> formatter) : formatter(std::move(formatter)) {}
Expand Down
2 changes: 1 addition & 1 deletion src/ll/core/CrashLogger_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ static LONG unhandledExceptionFilter(_In_ struct _EXCEPTION_POINTERS* e) {
crashInfo.date = fmt::format("{:%Y-%m-%d_%H-%M-%S}", fmt::localtime(_time64(nullptr)));
crashInfo.settings = ll::getLeviConfig().modules.crashLogger;
crashInfo.path = file_utils::u8path(pl::pl_log_path) / u8"crash";
auto formatter = makePolymorphic<io::PatternFormatter>("{tm:.3%T.} [{lvl}] {msg}", pl::pl_color_log);
auto formatter = makePolymorphic<io::PatternFormatter>("{tm:.3%T.} [{lvl}] {msg}");
formatter->styles[1] = {
{
{},
Expand Down

0 comments on commit e80d1c1

Please sign in to comment.