20#include <imgui-docking/imgui.h>
28namespace OpenShaderDesigner
39 SHOW_TIMESTAMP = 0b00000001
40 , SHOW_THREAD = 0b00000010
41 , SHOW_SEVERITY = 0b00000100
42 , SHOW_FILE_INFO = 0b00001000
43 , WRAP_TEXT = 0b00010000
46 , DEFAULT_SETTINGS = ALL_SETTINGS ^ WRAP_TEXT
54 "Timestamps",
"Thread IDs",
"Severity",
"File Info",
"Wrapping"
78 "Message",
"Warning",
"Error",
"Fatal",
"Alert",
"Command"
86 inline static constexpr ImVec4
ImGuiColor(
unsigned int RGB)
89 static_cast<float>((RGB >> 24) & 255) / 255.0f,
static_cast<float>((RGB >> 16) & 255) / 255.0f,
90 static_cast<float>((RGB >> 8) & 255) / 255.0f,
static_cast<float>((RGB >> 0) & 255) / 255.0f
102 static std::string ThreadID()
104 std::stringstream ss;
105 ss << std::this_thread::get_id();
118 template <
typename... Args>
119 static void Log(
const std::string& file
121 ,
Severity severity = Severity::DEFAULT
122 ,
const std::format_string<Args...>& message =
""
125 static void DrawMenu();
126 static void DrawWindow();
128 static inline bool Open =
true;
133 const std::string Message;
134 const Severity Severity;
135 const std::string File, Timestamp, Thread;
144 static std::string Format(
const LogEntry& entry,
Setting settings);
150 static void ProcessCommand(
const std::string& command);
152 inline static std::list<LogEntry> EntryLog;
153 inline static std::mutex Lock;
154 inline static int Filter =
static_cast<int>(0xFFFFFFFF);
155 inline static Setting Settings = DEFAULT_SETTINGS;
156 inline static std::string Command;
159 template <
typename... Args>
161 const std::string& file
164 ,
const std::format_string<Args...>& fmt
167 auto t = std::time(
nullptr);
169#pragma warning(disable:4996)
171 auto tm = *std::localtime(&t);
173 std::lock_guard guard(Lock);
175 std::vformat(fmt.get(), std::make_format_args(vargs...)), severity, file, std::format(
176 "{:0>2}:{:0>2}:{:0>2}", tm.tm_hour, tm.tm_min, tm.tm_sec),
179 EntryLog.push_back(entry);
180 std::cout << Format(entry, ALL_SETTINGS) << std::endl;
184#define Log(...) Log(__FILE__, __LINE__, __VA_ARGS__)
static const ImVec4 SeverityColors[]
Color for rendering each Severity level text in editor.
Definition Console.h:97
static void Log(const std::string &file, const int line, Severity severity=Severity::DEFAULT, const std::format_string< Args... > &message="", Args &&... vargs)
Thread-Safe Log function for debugging.
Definition Console.h:160
Setting
Setting for displaying log entries.
Definition Console.h:38
static const std::string SettingNames[]
String representations of the settings.
Definition Console.h:52
Severity
Severity levels for log entries.
Definition Console.h:62
static const std::string Severities[]
String representations of the Severity levels.
Definition Console.h:76
static constexpr ImVec4 ImGuiColor(unsigned int RGB)
Integer to floating point color. (ImGui APIVersion)
Definition Console.h:86