20 lines
585 B
C++
20 lines
585 B
C++
#pragma once
|
|
#include <string>
|
|
#include <functional>
|
|
|
|
enum class LogTag { Info, Ok, Warn, Err };
|
|
|
|
// Thread-safe console logger (stand-in for the python `push_log` + log_queue/SSE).
|
|
// Also supports a "sink" callback so the Discord bot can mirror log lines into
|
|
// a Discord channel/log command without polling a queue.
|
|
class Logger {
|
|
public:
|
|
using Sink = std::function<void(const std::string& ts, const std::string& msg, LogTag tag)>;
|
|
|
|
static void log(const std::string& msg, LogTag tag = LogTag::Info);
|
|
static void setSink(Sink sink);
|
|
|
|
private:
|
|
static Sink sink_;
|
|
};
|