22#include <imgui-docking/imgui.h>
31namespace OpenShaderDesigner
43 Settings_ShowTimeStamp = 0b00000001
44 , Settings_ShowThread = 0b00000010
45 , Settings_Severity = 0b00000100
46 , Settings_ShowFileInfo = 0b00001000
47 , Settings_WrapText = 0b00010000
50 , Settings_Default = Settings_ALL ^ Settings_WrapText
58 "Timestamps",
"Thread IDs",
"Severity",
"File Info",
"Wrapping"
82 "Message",
"Warning",
"Error",
"Fatal",
"Alert",
"Command"
90 inline static constexpr ImVec4
ImGuiColor(
unsigned int RGB)
93 static_cast<float>((RGB >> 24) & 255) / 255.0f,
static_cast<float>((RGB >> 16) & 255) / 255.0f,
94 static_cast<float>((RGB >> 8) & 255) / 255.0f,
static_cast<float>((RGB >> 0) & 255) / 255.0f
106 static std::string ThreadID()
108 std::stringstream ss;
109 ss << std::this_thread::get_id();
122 template <
typename... Args>
123 static void Log(
const std::string& file
125 ,
Severity severity = Severity::DEFAULT
126 ,
const std::format_string<Args...>& message =
""
129 static void DrawMenu();
130 static void DrawWindow();
132 static inline bool Open =
true;
137 const std::string Message;
138 const Severity Severity;
139 const std::string File, Timestamp, Thread;
148 static std::string Format(
const LogEntry& entry, uint8_t settings);
154 static void ProcessCommand(
const std::string& command);
156 inline static std::list<LogEntry> EntryLog_;
157 inline static std::mutex Lock_;
158 inline static int Filter_ =
static_cast<int>(0xFFFFFFFF);
159 inline static uint8_t Settings_ = Settings_Default;
160 inline static std::string CommandBuffer_;
163template <
typename... Args>
165 const std::string& file
168 ,
const std::format_string<Args...>& fmt
171 auto t = std::time(
nullptr);
173#pragma warning(disable:4996)
175 auto tm = *std::localtime(&t);
176 const auto rel = std::filesystem::relative(file, PROJECT_DIR).string();
178 std::lock_guard guard(Lock_);
180 std::vformat(fmt.get(), std::make_format_args(vargs...)), severity, rel, std::format(
181 "{:0>2}:{:0>2}:{:0>2}", tm.tm_hour, tm.tm_min, tm.tm_sec),
184 EntryLog_.push_back(entry);
185 std::cout << Format(entry, Settings_ALL) << std::endl;
190#define Log(...) Log(__FILE__, __LINE__, __VA_ARGS__)
static const ImVec4 SeverityColors[]
Color for rendering each Severity level text in editor.
Definition Console.h:101
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:164
static const std::string SettingNames[]
String representations of the settings.
Definition Console.h:56
Severity
Severity levels for log entries.
Definition Console.h:66
static const std::string Severities[]
String representations of the Severity levels.
Definition Console.h:80
static constexpr ImVec4 ImGuiColor(unsigned int RGB)
Integer to floating point color. (ImGui APIVersion)
Definition Console.h:90
Settings
Setting for displaying log entries.
Definition Console.h:42