CoriEngine
Loading...
Searching...
No Matches
Logger.hpp
Go to the documentation of this file.
1#ifndef LOGGER
2#define LOGGER
3#include <spdlog/spdlog.h>
4#include <spdlog/async.h>
5#include <spdlog/sinks/rotating_file_sink.h>
6#include <spdlog/fmt/ostr.h>
7#include <spdlog/fmt/bundled/color.h>
8#include <spdlog/fmt/bundled/base.h>
9#include <spdlog/fmt/bundled/format.h>
11
12#if defined(__clang__)
13#define BUGTRAP __builtin_debugtrap()
14#elif defined(__GNUC__)
15#define BUGTRAP __builtin_trap()
16#else
17#include <cstdlib>
18#define BUGTRAP std::abort()
19#endif
20
21
22namespace Cori {
23
27 class Logger {
28 public:
37
41 struct Tags {
42 struct AssetManager {
43 static constexpr char Self[] = "Asset Manager";
44 };
45
46 struct Graphics {
47 static constexpr char Self[] = "Graphics";
48
49 static constexpr char OpenGL[] = "OpenGL";
50 static constexpr char Vulkan[] = "Vulkan"; // unused for now
51
52 // API Tags
53 // Only used like this: [OpenGL] or [Vulkan] then [Tag]
54 // vvv
55
56 static constexpr char ShaderProgram[] = "Shader Program";
57 static constexpr char VertexBuffer[] = "Vertex Buffer";
58 static constexpr char IndexBuffer[] = "Index Buffer";
59 static constexpr char VertexArray[] = "Vertex Array";
60 static constexpr char Texture2D[] = "Texture2D";
61 static constexpr char GraphicsContext[] = "Graphics Context";
62 static constexpr char Font[] = "Font";
63
64 // Generic Tags
65 // vvv
66
67 static constexpr char Renderer2D[] = "Renderer2D";
68 static constexpr char Image[] = "Image";
69 static constexpr char SpriteAtlas[] = "Sprite Atlas";
70 static constexpr char Camera[] = "Camera";
71 static constexpr char AnimationPack[] = "Animation Pack";
72
73 };
74 struct Audio {
75 static constexpr char Self[] = "Audio";
76
77 static constexpr char Sound[] = "Sound";
78 static constexpr char Track[] = "Track";
79 static constexpr char Mixer[] = "Mixer";
80 };
81
82 struct Core {
83 static constexpr char Self[] = "Core";
84 struct Factory {
85 static constexpr char Self[] = "Factory";
86
87 static constexpr char SelfFactory[] = "Self Factory";
88 static constexpr char Register[] = "Register";
89 static constexpr char Shared[] = "Shared";
90 static constexpr char Unique[] = "Unique";
91 };
92
93 static constexpr char Logger[] = "Logger";
94 static constexpr char Layer[] = "Layer";
95 static constexpr char LayerStack[] = "LayerStack";
96 static constexpr char GameTimer[] = "GameTimer";
97 static constexpr char Window[] = "Window";
98 static constexpr char ImGui[] = "ImGui";
99 static constexpr char UUID[] = "UUID";
100 static constexpr char SceneManager[] = "Scene Manager";
101
102 };
103
104 struct FileSystem {
105 static constexpr char Self[] = "FileSystem";
106
107 static constexpr char BinaryFileManager[] = "Binary File Manager";
108 static constexpr char PathManager[] = "Path Manager";
109
110 };
111
112 struct Math {
113 static constexpr char Self[] = "Math";
114
115 static constexpr char Function[] = "Function";
116 };
117
118 struct World {
119 static constexpr char Self[] = "World";
120
121 struct Scene {
122 static constexpr char Self[] = "Scene";
123
124 };
125
126 struct Entity {
127 static constexpr char Self[] = "Entity";
128
129 static constexpr char Trigger[] = "Trigger";
130 static constexpr char StateMachine[] = "State Machine";
131 static constexpr char QuadRenderer[] = "Quad Renderer";
132 static constexpr char QuadAnimator[] = "Quad Animator";
133
134 };
135
136 struct Systems {
137 static constexpr char Self[] = "Entity";
138
139 static constexpr char Animation[] = "Animation";
140 };
141 };
142
143 struct Profiler {
144 static constexpr char Self[] = "Profiler";
145
146 static constexpr char InstanceMetrics[] = "Instance Metrics";
147 };
148
149 struct Utility {
150 static constexpr char Self[] = "Utility";
151
152 static constexpr char UTF[] = "UTF";
153 };
154
155 // Ungrouped tags
156 static constexpr char UnusedError[] = "Unused Error";
157 };
158
160
161 static void Init(bool async, bool fileWrite);
162
163 static bool GetStatus();
164
165 static std::shared_ptr<spdlog::logger>& GetCoreLogger() { return s_CoreLogger; }
166 static std::shared_ptr<spdlog::logger>& GetClientLogger() { return s_ClientLogger; }
167
168 static void SetCoreLogLevel(LogLevel level);
169 static void SetClientLogLevel(LogLevel level);
170
171 template<typename T>
172 static auto ColoredText(const T& text, const fmt::color c, const fmt::text_style s = fmt::text_style{}) {
173 return fmt::styled(text, fmt::fg(c) | s);
174 }
175
176 template<typename T>
177 static auto HighlightedText(const T& text, const fmt::color c, const fmt::text_style s = fmt::text_style{}) {
178 return fmt::styled(text, fmt::bg(c) | s);
179 }
180
181 static std::string BoolAlpha(const bool b) {
182 if (b) {
183 return "True";
184 }
185 return "False";
186 }
187
193 static void EnableCoreTag(const char* tag);
194
200 static void EnableCoreTags(const std::initializer_list<const char*> tags);
201
202
207 static void DisableCoreTag(const char* tag);
208
209
214 static void DisableCoreTags(const std::initializer_list<const char*> tags);
215
221 static bool IsCoreTagDisabled(const char* tag);
222
223
227 static void ClearCoreTagFilter();
228
233 static std::vector<std::string> GetCoreInactiveTags();
234
240 static void EnableClientTag(const char* tag);
241
247 static void EnableClientTags(const std::initializer_list<const char*> tags);
248
253 static void DisableClientTag(const char* tag);
254
259 static void DisableClientTags(const std::initializer_list<const char*> tags);
260
266 static bool IsClientTagDisabled(const char* tag);
267
271 static void ClearClientTagFilter();
272
277 static std::vector<std::string> GetClientInactiveTags();
278
279 template<typename... Args>
280 static void CoreLogTraceTagged(const std::initializer_list<const char*> tags, const fmt::format_string<Args...>& fmt, Args&&... args) {
281 if (ShouldCoreLog(tags)) {
282
283 fmt::memory_buffer buffer;
284
285 for (const char* tag : tags) {
286 fmt::format_to(std::back_inserter(buffer), "{}", fmt::styled(fmt::format("[{}]", tag), fmt::fg(fmt::color::thistle)));
287 }
288
289 buffer.push_back(' ');
290
291 const auto styled_dummy = fmt::format("{}", fmt::styled(" ", fmt::fg(fmt::color::light_cyan)));
292 const auto start_code_end = styled_dummy.find(' ');
293
294 const auto end_code_start = start_code_end + 1;
295 const std::string_view start_code(styled_dummy.data(), start_code_end);
296 const std::string_view end_code(styled_dummy.data() + end_code_start, styled_dummy.size() - end_code_start);
297
298 buffer.append(start_code);
299 fmt::vformat_to(std::back_inserter(buffer), fmt, fmt::make_format_args(args...));
300 buffer.append(end_code);
301
302 s_CoreLogger->trace(std::string_view(buffer.data(), buffer.size()));
303 }
304 }
305
306 template<typename... Args>
307 static void CoreLogDebugTagged(const std::initializer_list<const char*> tags, const fmt::format_string<Args...>& fmt, Args&&... args) {
308 if (ShouldCoreLog(tags)) {
309
310 fmt::memory_buffer buffer;
311
312 for (const char* tag : tags) {
313 fmt::format_to(std::back_inserter(buffer), "{}", fmt::styled(fmt::format("[{}]", tag), fmt::fg(fmt::color::cyan)));
314 }
315
316 buffer.push_back(' ');
317
318 const auto styled_dummy = fmt::format("{}", fmt::styled(" ", fmt::fg(fmt::color::royal_blue)));
319 const auto start_code_end = styled_dummy.find(' ');
320
321 const auto end_code_start = start_code_end + 1;
322 const std::string_view start_code(styled_dummy.data(), start_code_end);
323 const std::string_view end_code(styled_dummy.data() + end_code_start, styled_dummy.size() - end_code_start);
324
325 buffer.append(start_code);
326 fmt::vformat_to(std::back_inserter(buffer), fmt, fmt::make_format_args(args...));
327 buffer.append(end_code);
328
329 s_CoreLogger->debug(std::string_view(buffer.data(), buffer.size()));
330 }
331 }
332
333 template<typename... Args>
334 static void CoreLogInfoTagged(const std::initializer_list<const char*> tags, const fmt::format_string<Args...>& fmt, Args&&... args) {
335 if (ShouldCoreLog(tags)) {
336
337 fmt::memory_buffer buffer;
338
339 for (const char* tag : tags) {
340 fmt::format_to(std::back_inserter(buffer), "{}", fmt::styled(fmt::format("[{}]", tag), fmt::fg(fmt::color::lime)));
341 }
342
343 buffer.push_back(' ');
344
345 const auto styled_dummy = fmt::format("{}", fmt::styled(" ", fmt::fg(fmt::color::green_yellow)));
346
347 const auto start_code_end = styled_dummy.find(' ');
348
349 const auto end_code_start = start_code_end + 1;
350 const std::string_view start_code(styled_dummy.data(), start_code_end);
351 const std::string_view end_code(styled_dummy.data() + end_code_start, styled_dummy.size() - end_code_start);
352
353 buffer.append(start_code);
354 fmt::vformat_to(std::back_inserter(buffer), fmt, fmt::make_format_args(args...));
355 buffer.append(end_code);
356
357 s_CoreLogger->info(std::string_view(buffer.data(), buffer.size()));
358 }
359 }
360
361 template<typename... Args>
362 static void CoreLogWarnTagged(const std::initializer_list<const char*> tags, const fmt::format_string<Args...>& fmt, Args&&... args) {
363 if (ShouldCoreLog(tags)) {
364
365 fmt::memory_buffer buffer;
366
367 for (const char* tag : tags) {
368 fmt::format_to(std::back_inserter(buffer), "{}", fmt::styled(fmt::format("[{}]", tag), fmt::fg(fmt::color::yellow)));
369 }
370
371 buffer.push_back(' ');
372
373 const auto styled_dummy = fmt::format("{}", fmt::styled(" ", fmt::fg(fmt::color::orange)));
374 const auto start_code_end = styled_dummy.find(' ');
375
376 const auto end_code_start = start_code_end + 1;
377 const std::string_view start_code(styled_dummy.data(), start_code_end);
378 const std::string_view end_code(styled_dummy.data() + end_code_start, styled_dummy.size() - end_code_start);
379
380 buffer.append(start_code);
381 fmt::vformat_to(std::back_inserter(buffer), fmt, fmt::make_format_args(args...));
382 buffer.append(end_code);
383
384 s_CoreLogger->warn(std::string_view(buffer.data(), buffer.size()));
385 }
386 }
387
388 template<typename... Args>
389 static void CoreLogErrorTagged(const std::initializer_list<const char*> tags, const fmt::format_string<Args...>& fmt, Args&&... args) {
390 if (ShouldCoreLog(tags)) {
391
392 fmt::memory_buffer buffer;
393
394 for (const char* tag : tags) {
395 fmt::format_to(std::back_inserter(buffer), "{}", fmt::styled(fmt::format("[{}]", tag), fmt::fg(fmt::color::hot_pink)));
396 }
397
398 buffer.push_back(' ');
399
400 const auto styled_dummy = fmt::format("{}", fmt::styled(" ", fmt::fg(fmt::color::violet)));
401 const auto start_code_end = styled_dummy.find(' ');
402
403 const auto end_code_start = start_code_end + 1;
404 const std::string_view start_code(styled_dummy.data(), start_code_end);
405 const std::string_view end_code(styled_dummy.data() + end_code_start, styled_dummy.size() - end_code_start);
406
407 buffer.append(start_code);
408 fmt::vformat_to(std::back_inserter(buffer), fmt, fmt::make_format_args(args...));
409 buffer.append(end_code);
410
411 s_CoreLogger->error(std::string_view(buffer.data(), buffer.size()));
412 }
413 }
414
415 template<typename... Args>
416 static void CoreLogFatalTagged(const std::initializer_list<const char*> tags, const fmt::format_string<Args...>& fmt, Args&&... args) {
417 if (ShouldCoreLog(tags)) {
418
419 fmt::memory_buffer buffer;
420
421 for (const char* tag : tags) {
422 fmt::format_to(std::back_inserter(buffer), "{}", fmt::styled(fmt::format("[{}]", tag), fmt::bg(fmt::color::red)));
423 }
424
425 buffer.push_back(' ');
426
427 const auto styled_dummy = fmt::format("{}", fmt::styled(" ", fmt::bg(fmt::color::red)));
428 const auto start_code_end = styled_dummy.find(' ');
429
430 const auto end_code_start = start_code_end + 1;
431 const std::string_view start_code(styled_dummy.data(), start_code_end);
432 const std::string_view end_code(styled_dummy.data() + end_code_start, styled_dummy.size() - end_code_start);
433
434 buffer.append(start_code);
435 fmt::vformat_to(std::back_inserter(buffer), fmt, fmt::make_format_args(args...));
436 buffer.append(end_code);
437
438 s_CoreLogger->critical(std::string_view(buffer.data(), buffer.size()));
439 }
440 }
441
442
443
444 template<typename... Args>
445 static void ClientLogTraceTagged(const std::initializer_list<const char*> tags, const fmt::format_string<Args...>& fmt, Args&&... args) {
446 if (ShouldClientLog(tags)) {
447
448 fmt::memory_buffer buffer;
449
450 for (const char* tag : tags) {
451 fmt::format_to(std::back_inserter(buffer), "{}", fmt::styled(fmt::format("[{}]", tag), fmt::fg(fmt::color::thistle)));
452 }
453
454 buffer.push_back(' ');
455
456 const auto styled_dummy = fmt::format("{}", fmt::styled(" ", fmt::fg(fmt::color::light_cyan)));
457 const auto start_code_end = styled_dummy.find(' ');
458
459 const auto end_code_start = start_code_end + 1;
460 const std::string_view start_code(styled_dummy.data(), start_code_end);
461 const std::string_view end_code(styled_dummy.data() + end_code_start, styled_dummy.size() - end_code_start);
462
463 buffer.append(start_code);
464 fmt::vformat_to(std::back_inserter(buffer), fmt, fmt::make_format_args(args...));
465 buffer.append(end_code);
466
467 s_ClientLogger->trace(std::string_view(buffer.data(), buffer.size()));
468 }
469 }
470
471 template<typename... Args>
472 static void ClientLogDebugTagged(const std::initializer_list<const char*> tags, const fmt::format_string<Args...>& fmt, Args&&... args) {
473 if (ShouldClientLog(tags)) {
474
475 fmt::memory_buffer buffer;
476
477 for (const char* tag : tags) {
478 fmt::format_to(std::back_inserter(buffer), "{}", fmt::styled(fmt::format("[{}]", tag), fmt::fg(fmt::color::cyan)));
479 }
480
481 buffer.push_back(' ');
482
483 const auto styled_dummy = fmt::format("{}", fmt::styled(" ", fmt::fg(fmt::color::royal_blue)));
484 const auto start_code_end = styled_dummy.find(' ');
485
486 const auto end_code_start = start_code_end + 1;
487 const std::string_view start_code(styled_dummy.data(), start_code_end);
488 const std::string_view end_code(styled_dummy.data() + end_code_start, styled_dummy.size() - end_code_start);
489
490 buffer.append(start_code);
491 fmt::vformat_to(std::back_inserter(buffer), fmt, fmt::make_format_args(args...));
492 buffer.append(end_code);
493
494 s_ClientLogger->debug(std::string_view(buffer.data(), buffer.size()));
495 }
496 }
497
498 template<typename... Args>
499 static void ClientLogInfoTagged(const std::initializer_list<const char*> tags, const fmt::format_string<Args...>& fmt, Args&&... args) {
500 if (ShouldClientLog(tags)) {
501
502 fmt::memory_buffer buffer;
503
504 for (const char* tag : tags) {
505 fmt::format_to(std::back_inserter(buffer), "{}", fmt::styled(fmt::format("[{}]", tag), fmt::fg(fmt::color::lime)));
506 }
507
508 buffer.push_back(' ');
509
510 const auto styled_dummy = fmt::format("{}", fmt::styled(" ", fmt::fg(fmt::color::green_yellow)));
511 const auto start_code_end = styled_dummy.find(' ');
512
513 const auto end_code_start = start_code_end + 1;
514 const std::string_view start_code(styled_dummy.data(), start_code_end);
515 const std::string_view end_code(styled_dummy.data() + end_code_start, styled_dummy.size() - end_code_start);
516
517 buffer.append(start_code);
518 fmt::vformat_to(std::back_inserter(buffer), fmt, fmt::make_format_args(args...));
519 buffer.append(end_code);
520
521 s_ClientLogger->info(std::string_view(buffer.data(), buffer.size()));
522 }
523 }
524
525 template<typename... Args>
526 static void ClientLogWarnTagged(const std::initializer_list<const char*> tags, const fmt::format_string<Args...>& fmt, Args&&... args) {
527 if (ShouldClientLog(tags)) {
528
529 fmt::memory_buffer buffer;
530
531 for (const char* tag : tags) {
532 fmt::format_to(std::back_inserter(buffer), "{}", fmt::styled(fmt::format("[{}]", tag), fmt::fg(fmt::color::yellow)));
533 }
534
535 buffer.push_back(' ');
536
537 const auto styled_dummy = fmt::format("{}", fmt::styled(" ", fmt::fg(fmt::color::orange)));
538 const auto start_code_end = styled_dummy.find(' ');
539
540 const auto end_code_start = start_code_end + 1;
541 const std::string_view start_code(styled_dummy.data(), start_code_end);
542 const std::string_view end_code(styled_dummy.data() + end_code_start, styled_dummy.size() - end_code_start);
543
544 buffer.append(start_code);
545 fmt::vformat_to(std::back_inserter(buffer), fmt, fmt::make_format_args(args...));
546 buffer.append(end_code);
547
548 s_ClientLogger->warn(std::string_view(buffer.data(), buffer.size()));
549 }
550 }
551
552 template<typename... Args>
553 static void ClientLogErrorTagged(const std::initializer_list<const char*> tags, const fmt::format_string<Args...>& fmt, Args&&... args) {
554 if (ShouldClientLog(tags)) {
555
556 fmt::memory_buffer buffer;
557
558 for (const char* tag : tags) {
559 fmt::format_to(std::back_inserter(buffer), "{}", fmt::styled(fmt::format("[{}]", tag), fmt::fg(fmt::color::hot_pink)));
560 }
561
562 buffer.push_back(' ');
563
564 const auto styled_dummy = fmt::format("{}", fmt::styled(" ", fmt::fg(fmt::color::violet)));
565 const auto start_code_end = styled_dummy.find(' ');
566
567 const auto end_code_start = start_code_end + 1;
568 const std::string_view start_code(styled_dummy.data(), start_code_end);
569 const std::string_view end_code(styled_dummy.data() + end_code_start, styled_dummy.size() - end_code_start);
570
571 buffer.append(start_code);
572 fmt::vformat_to(std::back_inserter(buffer), fmt, fmt::make_format_args(args...));
573 buffer.append(end_code);
574
575 s_ClientLogger->error(std::string_view(buffer.data(), buffer.size()));
576 }
577 }
578
579 template<typename... Args>
580 static void ClientLogFatalTagged(const std::initializer_list<const char*> tags, const fmt::format_string<Args...>& fmt, Args&&... args) {
581 if (ShouldClientLog(tags)) {
582
583 fmt::memory_buffer buffer;
584
585 for (const char* tag : tags) {
586 fmt::format_to(std::back_inserter(buffer), "{}", fmt::styled(fmt::format("[{}]", tag), fmt::bg(fmt::color::red)));
587 }
588
589 buffer.push_back(' ');
590
591 const auto styled_dummy = fmt::format("{}", fmt::styled(" ", fmt::bg(fmt::color::red)));
592 const auto start_code_end = styled_dummy.find(' ');
593
594 const auto end_code_start = start_code_end + 1;
595 const std::string_view start_code(styled_dummy.data(), start_code_end);
596 const std::string_view end_code(styled_dummy.data() + end_code_start, styled_dummy.size() - end_code_start);
597
598 buffer.append(start_code);
599 fmt::vformat_to(std::back_inserter(buffer), fmt, fmt::make_format_args(args...));
600 buffer.append(end_code);
601
602 s_ClientLogger->critical(std::string_view(buffer.data(), buffer.size()));
603 }
604 }
605
606
607
608 template<typename... Args>
609 static void CoreLogTrace(const fmt::format_string<Args...>& fmt, Args&&... args) {
610 fmt::memory_buffer buffer;
611
612 const auto styled_dummy = fmt::format("{}", fmt::styled(" ", fmt::fg(fmt::color::light_cyan)));
613 const auto start_code_end = styled_dummy.find(' ');
614
615 const auto end_code_start = start_code_end + 1;
616 const std::string_view start_code(styled_dummy.data(), start_code_end);
617 const std::string_view end_code(styled_dummy.data() + end_code_start, styled_dummy.size() - end_code_start);
618
619 buffer.append(start_code);
620 fmt::vformat_to(std::back_inserter(buffer), fmt, fmt::make_format_args(args...));
621 buffer.append(end_code);
622
623 s_CoreLogger->trace(std::string_view(buffer.data(), buffer.size()));
624
625 }
626
627 template<typename... Args>
628 static void CoreLogDebug(const fmt::format_string<Args...>& fmt, Args&&... args) {
629 fmt::memory_buffer buffer;
630
631 const auto styled_dummy = fmt::format("{}", fmt::styled(" ", fmt::fg(fmt::color::royal_blue)));
632 const auto start_code_end = styled_dummy.find(' ');
633
634 const auto end_code_start = start_code_end + 1;
635 const std::string_view start_code(styled_dummy.data(), start_code_end);
636 const std::string_view end_code(styled_dummy.data() + end_code_start, styled_dummy.size() - end_code_start);
637
638 buffer.append(start_code);
639 fmt::vformat_to(std::back_inserter(buffer), fmt, fmt::make_format_args(args...));
640 buffer.append(end_code);
641
642 s_CoreLogger->debug(std::string_view(buffer.data(), buffer.size()));
643
644 }
645
646 template<typename... Args>
647 static void CoreLogInfo(const fmt::format_string<Args...>& fmt, Args&&... args) {
648 fmt::memory_buffer buffer;
649
650 const auto styled_dummy = fmt::format("{}", fmt::styled(" ", fmt::fg(fmt::color::green_yellow)));
651 const auto start_code_end = styled_dummy.find(' ');
652
653 const auto end_code_start = start_code_end + 1;
654 const std::string_view start_code(styled_dummy.data(), start_code_end);
655 const std::string_view end_code(styled_dummy.data() + end_code_start, styled_dummy.size() - end_code_start);
656
657 buffer.append(start_code);
658 fmt::vformat_to(std::back_inserter(buffer), fmt, fmt::make_format_args(args...));
659 buffer.append(end_code);
660
661 s_CoreLogger->info(std::string_view(buffer.data(), buffer.size()));
662
663 }
664
665 template<typename... Args>
666 static void CoreLogWarn(const fmt::format_string<Args...>& fmt, Args&&... args) {
667 fmt::memory_buffer buffer;
668
669 const auto styled_dummy = fmt::format("{}", fmt::styled(" ", fmt::fg(fmt::color::orange)));
670 const auto start_code_end = styled_dummy.find(' ');
671
672 const auto end_code_start = start_code_end + 1;
673 const std::string_view start_code(styled_dummy.data(), start_code_end);
674 const std::string_view end_code(styled_dummy.data() + end_code_start, styled_dummy.size() - end_code_start);
675
676 buffer.append(start_code);
677 fmt::vformat_to(std::back_inserter(buffer), fmt, fmt::make_format_args(args...));
678 buffer.append(end_code);
679
680 s_CoreLogger->warn(std::string_view(buffer.data(), buffer.size()));
681 }
682
683 template<typename... Args>
684 static void CoreLogError(const fmt::format_string<Args...>& fmt, Args&&... args) {
685 fmt::memory_buffer buffer;
686
687 const auto styled_dummy = fmt::format("{}", fmt::styled(" ", fmt::fg(fmt::color::violet)));
688 const auto start_code_end = styled_dummy.find(' ');
689
690 const auto end_code_start = start_code_end + 1;
691 const std::string_view start_code(styled_dummy.data(), start_code_end);
692 const std::string_view end_code(styled_dummy.data() + end_code_start, styled_dummy.size() - end_code_start);
693
694 buffer.append(start_code);
695 fmt::vformat_to(std::back_inserter(buffer), fmt, fmt::make_format_args(args...));
696 buffer.append(end_code);
697
698 s_CoreLogger->error(std::string_view(buffer.data(), buffer.size()));
699 }
700
701 template<typename... Args>
702 static void CoreLogFatal(const fmt::format_string<Args...>& fmt, Args&&... args) {
703 fmt::memory_buffer buffer;
704
705 const auto styled_dummy = fmt::format("{}", fmt::styled(" ", fmt::bg(fmt::color::red)));
706 const auto start_code_end = styled_dummy.find(' ');
707
708 const auto end_code_start = start_code_end + 1;
709 const std::string_view start_code(styled_dummy.data(), start_code_end);
710 const std::string_view end_code(styled_dummy.data() + end_code_start, styled_dummy.size() - end_code_start);
711
712 buffer.append(start_code);
713 fmt::vformat_to(std::back_inserter(buffer), fmt, fmt::make_format_args(args...));
714 buffer.append(end_code);
715
716 s_CoreLogger->critical(std::string_view(buffer.data(), buffer.size()));
717 }
718
719
720
721 template<typename... Args>
722 static void ClientLogTrace(const fmt::format_string<Args...>& fmt, Args&&... args) {
723 fmt::memory_buffer buffer;
724
725 const auto styled_dummy = fmt::format("{}", fmt::styled(" ", fmt::fg(fmt::color::light_cyan)));
726 const auto start_code_end = styled_dummy.find(' ');
727
728 const auto end_code_start = start_code_end + 1;
729 const std::string_view start_code(styled_dummy.data(), start_code_end);
730 const std::string_view end_code(styled_dummy.data() + end_code_start, styled_dummy.size() - end_code_start);
731
732 buffer.append(start_code);
733 fmt::vformat_to(std::back_inserter(buffer), fmt, fmt::make_format_args(args...));
734 buffer.append(end_code);
735
736 s_ClientLogger->trace(std::string_view(buffer.data(), buffer.size()));
737 }
738
739 template<typename... Args>
740 static void ClientLogDebug(const fmt::format_string<Args...>& fmt, Args&&... args) {
741 fmt::memory_buffer buffer;
742
743 const auto styled_dummy = fmt::format("{}", fmt::styled(" ", fmt::fg(fmt::color::royal_blue)));
744 const auto start_code_end = styled_dummy.find(' ');
745
746 const auto end_code_start = start_code_end + 1;
747 const std::string_view start_code(styled_dummy.data(), start_code_end);
748 const std::string_view end_code(styled_dummy.data() + end_code_start, styled_dummy.size() - end_code_start);
749
750 buffer.append(start_code);
751 fmt::vformat_to(std::back_inserter(buffer), fmt, fmt::make_format_args(args...));
752 buffer.append(end_code);
753
754 s_ClientLogger->debug(std::string_view(buffer.data(), buffer.size()));
755 }
756
757 template<typename... Args>
758 static void ClientLogInfo(const fmt::format_string<Args...>& fmt, Args&&... args) {
759 fmt::memory_buffer buffer;
760
761 const auto styled_dummy = fmt::format("{}", fmt::styled(" ", fmt::fg(fmt::color::green_yellow)));
762 const auto start_code_end = styled_dummy.find(' ');
763
764 const auto end_code_start = start_code_end + 1;
765 const std::string_view start_code(styled_dummy.data(), start_code_end);
766 const std::string_view end_code(styled_dummy.data() + end_code_start, styled_dummy.size() - end_code_start);
767
768 buffer.append(start_code);
769 fmt::vformat_to(std::back_inserter(buffer), fmt, fmt::make_format_args(args...));
770 buffer.append(end_code);
771
772 s_ClientLogger->info(std::string_view(buffer.data(), buffer.size()));
773 }
774
775 template<typename... Args>
776 static void ClientLogWarn(const fmt::format_string<Args...>& fmt, Args&&... args) {
777 fmt::memory_buffer buffer;
778
779 const auto styled_dummy = fmt::format("{}", fmt::styled(" ", fmt::fg(fmt::color::orange)));
780 const auto start_code_end = styled_dummy.find(' ');
781
782 const auto end_code_start = start_code_end + 1;
783 const std::string_view start_code(styled_dummy.data(), start_code_end);
784 const std::string_view end_code(styled_dummy.data() + end_code_start, styled_dummy.size() - end_code_start);
785
786 buffer.append(start_code);
787 fmt::vformat_to(std::back_inserter(buffer), fmt, fmt::make_format_args(args...));
788 buffer.append(end_code);
789
790 s_ClientLogger->warn(std::string_view(buffer.data(), buffer.size()));
791 }
792
793 template<typename... Args>
794 static void ClientLogError(const fmt::format_string<Args...>& fmt, Args&&... args) {
795 fmt::memory_buffer buffer;
796
797 const auto styled_dummy = fmt::format("{}", fmt::styled(" ", fmt::fg(fmt::color::violet)));
798 const auto start_code_end = styled_dummy.find(' ');
799
800 const auto end_code_start = start_code_end + 1;
801 const std::string_view start_code(styled_dummy.data(), start_code_end);
802 const std::string_view end_code(styled_dummy.data() + end_code_start, styled_dummy.size() - end_code_start);
803
804 buffer.append(start_code);
805 fmt::vformat_to(std::back_inserter(buffer), fmt, fmt::make_format_args(args...));
806 buffer.append(end_code);
807
808 s_ClientLogger->error(std::string_view(buffer.data(), buffer.size()));
809 }
810
811 template<typename... Args>
812 static void ClientLogFatal(const fmt::format_string<Args...>& fmt, Args&&... args) {
813 fmt::memory_buffer buffer;
814
815 const auto styled_dummy = fmt::format("{}", fmt::styled(" ", fmt::bg(fmt::color::red)));
816 const auto start_code_end = styled_dummy.find(' ');
817
818 const auto end_code_start = start_code_end + 1;
819 const std::string_view start_code(styled_dummy.data(), start_code_end);
820 const std::string_view end_code(styled_dummy.data() + end_code_start, styled_dummy.size() - end_code_start);
821
822 buffer.append(start_code);
823 fmt::vformat_to(std::back_inserter(buffer), fmt, fmt::make_format_args(args...));
824 buffer.append(end_code);
825
826 s_ClientLogger->critical(std::string_view(buffer.data(), buffer.size()));
827 }
828
829
830 static void SampleColors() {
831 GetCoreLogger()->debug("Sample Text Start Here!!!!!!!!!!!!!!!!!!!!");
832 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: alice_blue", fmt::color::alice_blue));
833 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: antique_white", fmt::color::antique_white));
834 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: aqua", fmt::color::aqua));
835 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: aquamarine", fmt::color::aquamarine));
836 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: azure", fmt::color::azure));
837 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: beige", fmt::color::beige));
838 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: bisque", fmt::color::bisque));
839 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: black", fmt::color::black));
840 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: blanched_almond", fmt::color::blanched_almond));
841 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: blue", fmt::color::blue));
842 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: blue_violet", fmt::color::blue_violet));
843 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: brown", fmt::color::brown));
844 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: burly_wood", fmt::color::burly_wood));
845 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: cadet_blue", fmt::color::cadet_blue));
846 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: chartreuse", fmt::color::chartreuse));
847 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: chocolate", fmt::color::chocolate));
848 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: coral", fmt::color::coral));
849 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: cornflower_blue", fmt::color::cornflower_blue));
850 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: cornsilk", fmt::color::cornsilk));
851 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: crimson", fmt::color::crimson));
852 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: cyan", fmt::color::cyan));
853 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: dark_blue", fmt::color::dark_blue));
854 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: dark_cyan", fmt::color::dark_cyan));
855 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: dark_golden_rod", fmt::color::dark_golden_rod));
856 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: dark_gray", fmt::color::dark_gray));
857 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: dark_green", fmt::color::dark_green));
858 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: dark_khaki", fmt::color::dark_khaki));
859 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: dark_magenta", fmt::color::dark_magenta));
860 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: dark_olive_green", fmt::color::dark_olive_green));
861 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: dark_orange", fmt::color::dark_orange));
862 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: dark_orchid", fmt::color::dark_orchid));
863 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: dark_red", fmt::color::dark_red));
864 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: dark_salmon", fmt::color::dark_salmon));
865 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: dark_sea_green", fmt::color::dark_sea_green));
866 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: dark_slate_blue", fmt::color::dark_slate_blue));
867 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: dark_slate_gray", fmt::color::dark_slate_gray));
868 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: dark_turquoise", fmt::color::dark_turquoise));
869 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: dark_violet", fmt::color::dark_violet));
870 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: deep_pink", fmt::color::deep_pink));
871 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: deep_sky_blue", fmt::color::deep_sky_blue));
872 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: dim_gray", fmt::color::dim_gray));
873 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: dodger_blue", fmt::color::dodger_blue));
874 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: fire_brick", fmt::color::fire_brick));
875 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: floral_white", fmt::color::floral_white));
876 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: forest_green", fmt::color::forest_green));
877 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: fuchsia", fmt::color::fuchsia));
878 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: gainsboro", fmt::color::gainsboro));
879 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: ghost_white", fmt::color::ghost_white));
880 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: gold", fmt::color::gold));
881 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: golden_rod", fmt::color::golden_rod));
882 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: gray", fmt::color::gray));
883 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: green", fmt::color::green));
884 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: green_yellow", fmt::color::green_yellow));
885 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: honey_dew", fmt::color::honey_dew));
886 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: hot_pink", fmt::color::hot_pink));
887 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: indian_red", fmt::color::indian_red));
888 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: indigo", fmt::color::indigo));
889 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: ivory", fmt::color::ivory));
890 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: khaki", fmt::color::khaki));
891 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: lavender", fmt::color::lavender));
892 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: lavender_blush", fmt::color::lavender_blush));
893 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: lawn_green", fmt::color::lawn_green));
894 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: lemon_chiffon", fmt::color::lemon_chiffon));
895 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: light_blue", fmt::color::light_blue));
896 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: light_coral", fmt::color::light_coral));
897 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: light_cyan", fmt::color::light_cyan));
898 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: light_golden_rod_yellow", fmt::color::light_golden_rod_yellow));
899 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: light_gray", fmt::color::light_gray));
900 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: light_green", fmt::color::light_green));
901 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: light_pink", fmt::color::light_pink));
902 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: light_salmon", fmt::color::light_salmon));
903 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: light_sea_green", fmt::color::light_sea_green));
904 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: light_sky_blue", fmt::color::light_sky_blue));
905 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: light_slate_gray", fmt::color::light_slate_gray));
906 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: light_steel_blue", fmt::color::light_steel_blue));
907 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: light_yellow", fmt::color::light_yellow));
908 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: lime", fmt::color::lime));
909 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: lime_green", fmt::color::lime_green));
910 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: linen", fmt::color::linen));
911 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: magenta", fmt::color::magenta));
912 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: maroon", fmt::color::maroon));
913 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: medium_aquamarine", fmt::color::medium_aquamarine));
914 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: medium_blue", fmt::color::medium_blue));
915 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: medium_orchid", fmt::color::medium_orchid));
916 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: medium_purple", fmt::color::medium_purple));
917 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: medium_sea_green", fmt::color::medium_sea_green));
918 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: medium_slate_blue", fmt::color::medium_slate_blue));
919 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: medium_spring_green", fmt::color::medium_spring_green));
920 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: medium_turquoise", fmt::color::medium_turquoise));
921 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: medium_violet_red", fmt::color::medium_violet_red));
922 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: midnight_blue", fmt::color::midnight_blue));
923 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: mint_cream", fmt::color::mint_cream));
924 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: misty_rose", fmt::color::misty_rose));
925 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: moccasin", fmt::color::moccasin));
926 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: navajo_white", fmt::color::navajo_white));
927 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: navy", fmt::color::navy));
928 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: old_lace", fmt::color::old_lace));
929 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: olive", fmt::color::olive));
930 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: olive_drab", fmt::color::olive_drab));
931 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: orange", fmt::color::orange));
932 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: orange_red", fmt::color::orange_red));
933 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: orchid", fmt::color::orchid));
934 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: pale_golden_rod", fmt::color::pale_golden_rod));
935 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: pale_green", fmt::color::pale_green));
936 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: pale_turquoise", fmt::color::pale_turquoise));
937 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: pale_violet_red", fmt::color::pale_violet_red));
938 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: papaya_whip", fmt::color::papaya_whip));
939 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: peach_puff", fmt::color::peach_puff));
940 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: peru", fmt::color::peru));
941 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: pink", fmt::color::pink));
942 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: plum", fmt::color::plum));
943 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: powder_blue", fmt::color::powder_blue));
944 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: purple", fmt::color::purple));
945 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: rebecca_purple", fmt::color::rebecca_purple));
946 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: red", fmt::color::red));
947 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: rosy_brown", fmt::color::rosy_brown));
948 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: royal_blue", fmt::color::royal_blue));
949 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: saddle_brown", fmt::color::saddle_brown));
950 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: salmon", fmt::color::salmon));
951 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: sandy_brown", fmt::color::sandy_brown));
952 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: sea_green", fmt::color::sea_green));
953 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: sea_shell", fmt::color::sea_shell));
954 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: sienna", fmt::color::sienna));
955 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: silver", fmt::color::silver));
956 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: sky_blue", fmt::color::sky_blue));
957 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: slate_blue", fmt::color::slate_blue));
958 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: slate_gray", fmt::color::slate_gray));
959 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: snow", fmt::color::snow));
960 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: spring_green", fmt::color::spring_green));
961 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: steel_blue", fmt::color::steel_blue));
962 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: tan", fmt::color::tan));
963 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: teal", fmt::color::teal));
964 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: thistle", fmt::color::thistle));
965 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: tomato", fmt::color::tomato));
966 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: turquoise", fmt::color::turquoise));
967 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: violet", fmt::color::violet));
968 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: wheat", fmt::color::wheat));
969 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: white", fmt::color::white));
970 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: white_smoke", fmt::color::white_smoke));
971 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: yellow", fmt::color::yellow));
972 GetCoreLogger()->debug("{}", ColoredText("Sample Text color: yellow_green", fmt::color::yellow_green));
973 }
974
975 private:
976 static bool ShouldCoreLog(std::initializer_list<const char*> tags);
977 static bool ShouldClientLog(std::initializer_list<const char*> tags);
978
979 static bool s_Initialized;
980
981 struct StringHash {
982 using is_transparent = void;
983 [[nodiscard]] size_t operator()(const char* txt) const {
984 return std::hash<std::string_view>{}(txt);
985 }
986 [[nodiscard]] size_t operator()(const std::string_view txt) const {
987 return std::hash<std::string_view>{}(txt);
988 }
989 [[nodiscard]] size_t operator()(const std::string& txt) const {
990 return std::hash<std::string_view>{}(txt);
991 }
992 };
993
994 static std::shared_ptr<spdlog::logger> s_CoreLogger;
995 static std::shared_ptr<spdlog::logger> s_ClientLogger;
996 static std::unordered_set<std::string, StringHash, std::equal_to<>> s_CoreInactiveTags;
997 static std::unordered_set<std::string, StringHash, std::equal_to<>> s_ClientInactiveTags;
998 };
999}
1000
1001inline const std::string CORI_SECOND_LINE_SPACING = "[" + std::string(43, '-') + "]: ";
1002
1003//#define DISABLE_LOGGING
1004
1005// vvv Engine Side
1006#if defined(DEBUG_BUILD) && !defined(DISABLE_LOGGING)
1007
1008 #define CORI_CORE_TRACE(...) ::Cori::Logger::CoreLogTrace(__VA_ARGS__)
1009 #define CORI_CORE_DEBUG(...) ::Cori::Logger::CoreLogDebug(__VA_ARGS__)
1010 #define CORI_CORE_INFO(...) ::Cori::Logger::CoreLogInfo(__VA_ARGS__)
1011
1012 #define CORI_CORE_TRACE_TAGGED(...) ::Cori::Logger::CoreLogTraceTagged(__VA_ARGS__)
1013 #define CORI_CORE_DEBUG_TAGGED(...) ::Cori::Logger::CoreLogDebugTagged(__VA_ARGS__)
1014 #define CORI_CORE_INFO_TAGGED(...) ::Cori::Logger::CoreLogInfoTagged(__VA_ARGS__)
1015
1016 #define CORI_CORE_ASSERT(x, ...) if (!(x)) { (SPDLOG_LOGGER_CRITICAL(::Cori::Logger::GetCoreLogger(), "Assertion '"#x"' Failed. Message: " __VA_ARGS__), ::Cori::Logger::GetCoreLogger()->critical(" Function: {}", __PRETTY_FUNCTION__), spdlog::shutdown(), BUGTRAP); }
1017 #define CORI_CORE_VERIFY(x, ...) (!(x) ? (SPDLOG_LOGGER_CRITICAL(::Cori::Logger::GetCoreLogger(), "Verify '"#x"' Failed. Message: " __VA_ARGS__), ::Cori::Logger::GetCoreLogger()->critical(" Function: {}", __PRETTY_FUNCTION__), true) : false)
1018
1019#else
1020
1021 #define CORI_CORE_TRACE(...)
1022 #define CORI_CORE_DEBUG(...)
1023 #define CORI_CORE_INFO(...)
1024
1025 #define CORI_CORE_TRACE_TAGGED(...)
1026 #define CORI_CORE_DEBUG_TAGGED(...)
1027 #define CORI_CORE_INFO_TAGGED(...)
1028
1029 #define CORI_CORE_ASSERT(x, ...)
1030 #define CORI_CORE_VERIFY(x, ...) (!x)
1031
1032#endif
1033
1034#define CORI_CORE_WARN(...) ::Cori::Logger::CoreLogWarn(__VA_ARGS__)
1035#define CORI_CORE_ERROR(...) ::Cori::Logger::CoreLogError(__VA_ARGS__)
1036#define CORI_CORE_FATAL(...) ::Cori::Logger::CoreLogFatal(__VA_ARGS__)
1037
1038#define CORI_CORE_WARN_TAGGED(...) ::Cori::Logger::CoreLogWarnTagged(__VA_ARGS__)
1039#define CORI_CORE_ERROR_TAGGED(...) ::Cori::Logger::CoreLogErrorTagged(__VA_ARGS__)
1040#define CORI_CORE_FATAL_TAGGED(...) ::Cori::Logger::CoreLogFatalTagged(__VA_ARGS__)
1041
1042#define CORI_CORE_CHECK(x, ...) (!(x) ? (SPDLOG_LOGGER_ERROR(::Cori::Logger::GetCoreLogger(), "Check '"#x"' Failed. Message: " __VA_ARGS__), ::Cori::Logger::GetCoreLogger()->error(" Function: {}", __PRETTY_FUNCTION__), true) : false)
1043#define CORI_CORE_CHECK_EXPECTED(x) CORI_CORE_CHECK(x, "std::expected returned an error, message: {}", x.error().what())
1044
1045// vvv User Side
1046
1047#define CORI_ASSERT(x, ...) if (!(x)) { (SPDLOG_LOGGER_CRITICAL(::Cori::Logger::GetClientLogger(), "Assertion '"#x"' Failed. Message: " __VA_ARGS__), ::Cori::Logger::GetClientLogger()->critical(" Function: {}", __PRETTY_FUNCTION__), spdlog::shutdown(), BUGTRAP); }
1048#define CORI_VERIFY(x, ...) (!(x) ? (SPDLOG_LOGGER_CRITICAL(::Cori::Logger::GetClientLogger(), "Verify '"#x"' Failed. Message: " __VA_ARGS__), ::Cori::Logger::GetClientLogger()->critical(" Function: {}", __PRETTY_FUNCTION__), true) : false)
1049#define CORI_CHECK(x, ...) (!(x) ? (SPDLOG_LOGGER_ERROR(::Cori::Logger::GetClientLogger(), "Check '"#x"' Failed. Message: " __VA_ARGS__), ::Cori::Logger::GetClientLogger()->error(" Function: {}", __PRETTY_FUNCTION__), true) : false)
1050#define CORI_CHECK_EXPECTED(x) CORI_CHECK(x, "std::expected returned an error, message: {}", x.error().what())
1051
1052#define CORI_TRACE(...) ::Cori::Logger::ClientLogTrace(__VA_ARGS__)
1053#define CORI_DEBUG(...) ::Cori::Logger::ClientLogDebug(__VA_ARGS__)
1054#define CORI_INFO(...) ::Cori::Logger::ClientLogInfo(__VA_ARGS__)
1055#define CORI_WARN(...) ::Cori::Logger::ClientLogWarn(__VA_ARGS__)
1056#define CORI_ERROR(...) ::Cori::Logger::ClientLogError(__VA_ARGS__)
1057#define CORI_FATAL(...) ::Cori::Logger::ClientLogFatal(__VA_ARGS__)
1058
1059#define CORI_TRACE_TAGGED(...) ::Cori::Logger::ClientLogTraceTagged(__VA_ARGS__)
1060#define CORI_DEBUG_TAGGED(...) ::Cori::Logger::ClientLogDebugTagged(__VA_ARGS__)
1061#define CORI_INFO_TAGGED(...) ::Cori::Logger::ClientLogInfoTagged(__VA_ARGS__)
1062#define CORI_WARN_TAGGED(...) ::Cori::Logger::ClientLogWarnTagged(__VA_ARGS__)
1063#define CORI_ERROR_TAGGED(...) ::Cori::Logger::ClientLogErrorTagged(__VA_ARGS__)
1064#define CORI_FATAL_TAGGED(...) ::Cori::Logger::ClientLogFatalTagged(__VA_ARGS__)
1065
1066#endif
const std::string CORI_SECOND_LINE_SPACING
Definition Logger.hpp:1001
Logger is the first thing that is initialized during startup. Does console and file logging.
Definition Logger.hpp:27
static void EnableClientTag(const char *tag)
Enables the logging of a specific client tag.
Definition Logger.cpp:199
static auto HighlightedText(const T &text, const fmt::color c, const fmt::text_style s=fmt::text_style{})
Definition Logger.hpp:177
static void ClientLogDebug(const fmt::format_string< Args... > &fmt, Args &&... args)
Definition Logger.hpp:740
static void CoreLogError(const fmt::format_string< Args... > &fmt, Args &&... args)
Definition Logger.hpp:684
static void CoreLogFatal(const fmt::format_string< Args... > &fmt, Args &&... args)
Definition Logger.hpp:702
static void EnableClientTags(const std::initializer_list< const char * > tags)
Same as EnableClientTag but enables multiple tags at once.
Definition Logger.cpp:204
static void CoreLogTraceTagged(const std::initializer_list< const char * > tags, const fmt::format_string< Args... > &fmt, Args &&... args)
Definition Logger.hpp:280
static void CoreLogWarnTagged(const std::initializer_list< const char * > tags, const fmt::format_string< Args... > &fmt, Args &&... args)
Definition Logger.hpp:362
static void ClearCoreTagFilter()
Clears the core tag filter, all tags that were disabled become enabled again as a result.
Definition Logger.cpp:186
static void ClientLogTrace(const fmt::format_string< Args... > &fmt, Args &&... args)
Definition Logger.hpp:722
static void SampleColors()
Definition Logger.hpp:830
static bool IsClientTagDisabled(const char *tag)
Checks if a specific client tag is enabled.
Definition Logger.cpp:225
static void ClientLogFatal(const fmt::format_string< Args... > &fmt, Args &&... args)
Definition Logger.hpp:812
static void SetClientLogLevel(LogLevel level)
Definition Logger.cpp:99
static void CoreLogDebugTagged(const std::initializer_list< const char * > tags, const fmt::format_string< Args... > &fmt, Args &&... args)
Definition Logger.hpp:307
static auto ColoredText(const T &text, const fmt::color c, const fmt::text_style s=fmt::text_style{})
Definition Logger.hpp:172
static std::shared_ptr< spdlog::logger > & GetClientLogger()
Definition Logger.hpp:166
static void EnableCoreTags(const std::initializer_list< const char * > tags)
Same as EnableCoreTag but enables multiple tags at once.
Definition Logger.cpp:162
static void CoreLogDebug(const fmt::format_string< Args... > &fmt, Args &&... args)
Definition Logger.hpp:628
static void CoreLogFatalTagged(const std::initializer_list< const char * > tags, const fmt::format_string< Args... > &fmt, Args &&... args)
Definition Logger.hpp:416
static void CoreLogInfo(const fmt::format_string< Args... > &fmt, Args &&... args)
Definition Logger.hpp:647
static void DisableCoreTags(const std::initializer_list< const char * > tags)
Same as DisableCoreTag but disables multiple tags at once.
Definition Logger.cpp:174
static void DisableCoreTag(const char *tag)
Disables the logging of a specific core tag.
Definition Logger.cpp:169
static std::shared_ptr< spdlog::logger > & GetCoreLogger()
Definition Logger.hpp:165
static void ClientLogInfo(const fmt::format_string< Args... > &fmt, Args &&... args)
Definition Logger.hpp:758
static void ClientLogFatalTagged(const std::initializer_list< const char * > tags, const fmt::format_string< Args... > &fmt, Args &&... args)
Definition Logger.hpp:580
static void ClientLogTraceTagged(const std::initializer_list< const char * > tags, const fmt::format_string< Args... > &fmt, Args &&... args)
Definition Logger.hpp:445
static bool GetStatus()
Definition Logger.cpp:95
static void CoreLogErrorTagged(const std::initializer_list< const char * > tags, const fmt::format_string< Args... > &fmt, Args &&... args)
Definition Logger.hpp:389
static void ClientLogErrorTagged(const std::initializer_list< const char * > tags, const fmt::format_string< Args... > &fmt, Args &&... args)
Definition Logger.hpp:553
static std::vector< std::string > GetClientInactiveTags()
Gies a list of all currently disabled client tags.
Definition Logger.cpp:236
static void CoreLogInfoTagged(const std::initializer_list< const char * > tags, const fmt::format_string< Args... > &fmt, Args &&... args)
Definition Logger.hpp:334
static void SetCoreLogLevel(LogLevel level)
Definition Logger.cpp:128
static void CoreLogWarn(const fmt::format_string< Args... > &fmt, Args &&... args)
Definition Logger.hpp:666
static std::vector< std::string > GetCoreInactiveTags()
Gies a list of all currently disabled core tags.
Definition Logger.cpp:192
static void ClearClientTagFilter()
Clears the client tag filter, all tags that were disabled become enabled again as a result.
Definition Logger.cpp:230
static void ClientLogWarnTagged(const std::initializer_list< const char * > tags, const fmt::format_string< Args... > &fmt, Args &&... args)
Definition Logger.hpp:526
static void ClientLogError(const fmt::format_string< Args... > &fmt, Args &&... args)
Definition Logger.hpp:794
static void ClientLogInfoTagged(const std::initializer_list< const char * > tags, const fmt::format_string< Args... > &fmt, Args &&... args)
Definition Logger.hpp:499
static void CoreLogTrace(const fmt::format_string< Args... > &fmt, Args &&... args)
Definition Logger.hpp:609
static void ClientLogDebugTagged(const std::initializer_list< const char * > tags, const fmt::format_string< Args... > &fmt, Args &&... args)
Definition Logger.hpp:472
static void EnableVirtualTerminalProcessing()
Definition Logger.cpp:23
static void Init(bool async, bool fileWrite)
Definition Logger.cpp:43
static void DisableClientTag(const char *tag)
Disables the logging of a specific core tag.
Definition Logger.cpp:211
static std::string BoolAlpha(const bool b)
Definition Logger.hpp:181
static void EnableCoreTag(const char *tag)
Enables the logging of a specific core tag.
Definition Logger.cpp:157
static void ClientLogWarn(const fmt::format_string< Args... > &fmt, Args &&... args)
Definition Logger.hpp:776
static bool IsCoreTagDisabled(const char *tag)
Checks if a specific core tag is enabled.
Definition Logger.cpp:181
static void DisableClientTags(const std::initializer_list< const char * > tags)
Same as DisableClientTag but disables multiple tags at once.
Definition Logger.cpp:216
Global engine namespace.
static constexpr char Self[]
Definition Logger.hpp:43
static constexpr char Mixer[]
Definition Logger.hpp:79
static constexpr char Self[]
Definition Logger.hpp:75
static constexpr char Sound[]
Definition Logger.hpp:77
static constexpr char Track[]
Definition Logger.hpp:78
static constexpr char Register[]
Definition Logger.hpp:88
static constexpr char Self[]
Definition Logger.hpp:85
static constexpr char SelfFactory[]
Definition Logger.hpp:87
static constexpr char Shared[]
Definition Logger.hpp:89
static constexpr char Unique[]
Definition Logger.hpp:90
static constexpr char Window[]
Definition Logger.hpp:97
static constexpr char GameTimer[]
Definition Logger.hpp:96
static constexpr char LayerStack[]
Definition Logger.hpp:95
static constexpr char SceneManager[]
Definition Logger.hpp:100
static constexpr char Self[]
Definition Logger.hpp:83
static constexpr char Layer[]
Definition Logger.hpp:94
static constexpr char ImGui[]
Definition Logger.hpp:98
static constexpr char UUID[]
Definition Logger.hpp:99
static constexpr char Logger[]
Definition Logger.hpp:93
static constexpr char PathManager[]
Definition Logger.hpp:108
static constexpr char Self[]
Definition Logger.hpp:105
static constexpr char BinaryFileManager[]
Definition Logger.hpp:107
static constexpr char GraphicsContext[]
Definition Logger.hpp:61
static constexpr char Renderer2D[]
Definition Logger.hpp:67
static constexpr char OpenGL[]
Definition Logger.hpp:49
static constexpr char Texture2D[]
Definition Logger.hpp:60
static constexpr char IndexBuffer[]
Definition Logger.hpp:58
static constexpr char Camera[]
Definition Logger.hpp:70
static constexpr char VertexArray[]
Definition Logger.hpp:59
static constexpr char Image[]
Definition Logger.hpp:68
static constexpr char Font[]
Definition Logger.hpp:62
static constexpr char ShaderProgram[]
Definition Logger.hpp:56
static constexpr char VertexBuffer[]
Definition Logger.hpp:57
static constexpr char Vulkan[]
Definition Logger.hpp:50
static constexpr char SpriteAtlas[]
Definition Logger.hpp:69
static constexpr char Self[]
Definition Logger.hpp:47
static constexpr char AnimationPack[]
Definition Logger.hpp:71
static constexpr char Function[]
Definition Logger.hpp:115
static constexpr char Self[]
Definition Logger.hpp:113
static constexpr char Self[]
Definition Logger.hpp:144
static constexpr char InstanceMetrics[]
Definition Logger.hpp:146
static constexpr char Self[]
Definition Logger.hpp:150
static constexpr char UTF[]
Definition Logger.hpp:152
static constexpr char Self[]
Definition Logger.hpp:127
static constexpr char StateMachine[]
Definition Logger.hpp:130
static constexpr char QuadAnimator[]
Definition Logger.hpp:132
static constexpr char QuadRenderer[]
Definition Logger.hpp:131
static constexpr char Trigger[]
Definition Logger.hpp:129
static constexpr char Self[]
Definition Logger.hpp:122
static constexpr char Animation[]
Definition Logger.hpp:139
static constexpr char Self[]
Definition Logger.hpp:137
static constexpr char Self[]
Definition Logger.hpp:119
Available logger tags in somewhat hierarchical state. These are used in CORI_DEBUGLEVEL_CORE_TAGGED l...
Definition Logger.hpp:41
static constexpr char UnusedError[]
Definition Logger.hpp:156