diff options
| author | 2024-05-01 18:18:47 +0100 | |
|---|---|---|
| committer | 2024-05-01 18:18:47 +0100 | |
| commit | dd765c185a6a7a344f40d95a1862efe80ee2ece1 (patch) | |
| tree | 890fbae6aa095c8039fb311cdf92710d43900484 /src/logging.cpp | |
| parent | Splat the unused hops field in the 1206 SERVER message. (diff) | |
Switch --(protocol)debug to use a custom logger.
Diffstat (limited to 'src/logging.cpp')
| -rw-r--r-- | src/logging.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/logging.cpp b/src/logging.cpp index 01cb87d3c..74de6ad12 100644 --- a/src/logging.cpp +++ b/src/logging.cpp @@ -21,6 +21,8 @@ #include "clientprotocolmsg.h" #include "timeutils.h" +#include <fmt/color.h> + const char* Log::LevelToString(Log::Level level) { switch (level) @@ -51,6 +53,21 @@ void Log::NotifyRawIO(LocalUser* user, MessageType type) user->Send(ServerInstance->GetRFCEvents().privmsg, msg); } +class DebugLogMethod final + : public Log::Method +{ +public: + void OnLog(time_t time, Log::Level level, const std::string& type, const std::string& message) override + { + fmt::println("{} {}: {}", + fmt::styled(Time::ToString(time, "%d %b %Y %H:%M:%S"), fmt::fg(fmt::terminal_color::yellow)), + fmt::styled(type, fmt::fg(fmt::terminal_color::green)), + message + ); + } +}; + + Log::FileMethod::FileMethod(const std::string& n, FILE* fh, unsigned long fl, bool ac) : Timer(15*60, true) , autoclose(ac) @@ -181,7 +198,7 @@ void Log::Manager::CloseLogs() void Log::Manager::EnableDebugMode() { TokenList types = std::string("*"); - MethodPtr method = stdoutlog.Create(ServerInstance->Config->EmptyTag); + MethodPtr method = std::make_shared<DebugLogMethod>(); if (ServerInstance->Config->CommandLine.forceprotodebug) { |
