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>
13#define BUGTRAP __builtin_debugtrap()
14#elif defined(__GNUC__)
15#define BUGTRAP __builtin_trap()
18#define BUGTRAP std::abort()
43 static constexpr char Self[] =
"Asset Manager";
47 static constexpr char Self[] =
"Graphics";
49 static constexpr char OpenGL[] =
"OpenGL";
50 static constexpr char Vulkan[] =
"Vulkan";
62 static constexpr char Font[] =
"Font";
68 static constexpr char Image[] =
"Image";
70 static constexpr char Camera[] =
"Camera";
75 static constexpr char Self[] =
"Audio";
77 static constexpr char Sound[] =
"Sound";
78 static constexpr char Track[] =
"Track";
79 static constexpr char Mixer[] =
"Mixer";
83 static constexpr char Self[] =
"Core";
85 static constexpr char Self[] =
"Factory";
89 static constexpr char Shared[] =
"Shared";
90 static constexpr char Unique[] =
"Unique";
93 static constexpr char Logger[] =
"Logger";
94 static constexpr char Layer[] =
"Layer";
97 static constexpr char Window[] =
"Window";
98 static constexpr char ImGui[] =
"ImGui";
99 static constexpr char UUID[] =
"UUID";
105 static constexpr char Self[] =
"FileSystem";
113 static constexpr char Self[] =
"Math";
119 static constexpr char Self[] =
"World";
122 static constexpr char Self[] =
"Scene";
127 static constexpr char Self[] =
"Entity";
137 static constexpr char Self[] =
"Entity";
144 static constexpr char Self[] =
"Profiler";
150 static constexpr char Self[] =
"Utility";
152 static constexpr char UTF[] =
"UTF";
161 static void Init(
bool async,
bool fileWrite);
165 static std::shared_ptr<spdlog::logger>&
GetCoreLogger() {
return s_CoreLogger; }
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);
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);
200 static void EnableCoreTags(
const std::initializer_list<const char*> tags);
214 static void DisableCoreTags(
const std::initializer_list<const char*> tags);
247 static void EnableClientTags(
const std::initializer_list<const char*> tags);
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)) {
283 fmt::memory_buffer buffer;
285 for (
const char* tag : tags) {
286 fmt::format_to(std::back_inserter(buffer),
"{}", fmt::styled(fmt::format(
"[{}]", tag), fmt::fg(fmt::color::thistle)));
289 buffer.push_back(
' ');
291 const auto styled_dummy = fmt::format(
"{}", fmt::styled(
" ", fmt::fg(fmt::color::light_cyan)));
292 const auto start_code_end = styled_dummy.find(
' ');
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);
298 buffer.append(start_code);
299 fmt::vformat_to(std::back_inserter(buffer), fmt, fmt::make_format_args(args...));
300 buffer.append(end_code);
302 s_CoreLogger->trace(std::string_view(buffer.data(), buffer.size()));
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)) {
310 fmt::memory_buffer buffer;
312 for (
const char* tag : tags) {
313 fmt::format_to(std::back_inserter(buffer),
"{}", fmt::styled(fmt::format(
"[{}]", tag), fmt::fg(fmt::color::cyan)));
316 buffer.push_back(
' ');
318 const auto styled_dummy = fmt::format(
"{}", fmt::styled(
" ", fmt::fg(fmt::color::royal_blue)));
319 const auto start_code_end = styled_dummy.find(
' ');
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);
325 buffer.append(start_code);
326 fmt::vformat_to(std::back_inserter(buffer), fmt, fmt::make_format_args(args...));
327 buffer.append(end_code);
329 s_CoreLogger->debug(std::string_view(buffer.data(), buffer.size()));
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)) {
337 fmt::memory_buffer buffer;
339 for (
const char* tag : tags) {
340 fmt::format_to(std::back_inserter(buffer),
"{}", fmt::styled(fmt::format(
"[{}]", tag), fmt::fg(fmt::color::lime)));
343 buffer.push_back(
' ');
345 const auto styled_dummy = fmt::format(
"{}", fmt::styled(
" ", fmt::fg(fmt::color::green_yellow)));
347 const auto start_code_end = styled_dummy.find(
' ');
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);
353 buffer.append(start_code);
354 fmt::vformat_to(std::back_inserter(buffer), fmt, fmt::make_format_args(args...));
355 buffer.append(end_code);
357 s_CoreLogger->info(std::string_view(buffer.data(), buffer.size()));
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)) {
365 fmt::memory_buffer buffer;
367 for (
const char* tag : tags) {
368 fmt::format_to(std::back_inserter(buffer),
"{}", fmt::styled(fmt::format(
"[{}]", tag), fmt::fg(fmt::color::yellow)));
371 buffer.push_back(
' ');
373 const auto styled_dummy = fmt::format(
"{}", fmt::styled(
" ", fmt::fg(fmt::color::orange)));
374 const auto start_code_end = styled_dummy.find(
' ');
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);
380 buffer.append(start_code);
381 fmt::vformat_to(std::back_inserter(buffer), fmt, fmt::make_format_args(args...));
382 buffer.append(end_code);
384 s_CoreLogger->warn(std::string_view(buffer.data(), buffer.size()));
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)) {
392 fmt::memory_buffer buffer;
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)));
398 buffer.push_back(
' ');
400 const auto styled_dummy = fmt::format(
"{}", fmt::styled(
" ", fmt::fg(fmt::color::violet)));
401 const auto start_code_end = styled_dummy.find(
' ');
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);
407 buffer.append(start_code);
408 fmt::vformat_to(std::back_inserter(buffer), fmt, fmt::make_format_args(args...));
409 buffer.append(end_code);
411 s_CoreLogger->error(std::string_view(buffer.data(), buffer.size()));
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)) {
419 fmt::memory_buffer buffer;
421 for (
const char* tag : tags) {
422 fmt::format_to(std::back_inserter(buffer),
"{}", fmt::styled(fmt::format(
"[{}]", tag), fmt::bg(fmt::color::red)));
425 buffer.push_back(
' ');
427 const auto styled_dummy = fmt::format(
"{}", fmt::styled(
" ", fmt::bg(fmt::color::red)));
428 const auto start_code_end = styled_dummy.find(
' ');
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);
434 buffer.append(start_code);
435 fmt::vformat_to(std::back_inserter(buffer), fmt, fmt::make_format_args(args...));
436 buffer.append(end_code);
438 s_CoreLogger->critical(std::string_view(buffer.data(), buffer.size()));
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)) {
448 fmt::memory_buffer buffer;
450 for (
const char* tag : tags) {
451 fmt::format_to(std::back_inserter(buffer),
"{}", fmt::styled(fmt::format(
"[{}]", tag), fmt::fg(fmt::color::thistle)));
454 buffer.push_back(
' ');
456 const auto styled_dummy = fmt::format(
"{}", fmt::styled(
" ", fmt::fg(fmt::color::light_cyan)));
457 const auto start_code_end = styled_dummy.find(
' ');
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);
463 buffer.append(start_code);
464 fmt::vformat_to(std::back_inserter(buffer), fmt, fmt::make_format_args(args...));
465 buffer.append(end_code);
467 s_ClientLogger->trace(std::string_view(buffer.data(), buffer.size()));
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)) {
475 fmt::memory_buffer buffer;
477 for (
const char* tag : tags) {
478 fmt::format_to(std::back_inserter(buffer),
"{}", fmt::styled(fmt::format(
"[{}]", tag), fmt::fg(fmt::color::cyan)));
481 buffer.push_back(
' ');
483 const auto styled_dummy = fmt::format(
"{}", fmt::styled(
" ", fmt::fg(fmt::color::royal_blue)));
484 const auto start_code_end = styled_dummy.find(
' ');
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);
490 buffer.append(start_code);
491 fmt::vformat_to(std::back_inserter(buffer), fmt, fmt::make_format_args(args...));
492 buffer.append(end_code);
494 s_ClientLogger->debug(std::string_view(buffer.data(), buffer.size()));
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)) {
502 fmt::memory_buffer buffer;
504 for (
const char* tag : tags) {
505 fmt::format_to(std::back_inserter(buffer),
"{}", fmt::styled(fmt::format(
"[{}]", tag), fmt::fg(fmt::color::lime)));
508 buffer.push_back(
' ');
510 const auto styled_dummy = fmt::format(
"{}", fmt::styled(
" ", fmt::fg(fmt::color::green_yellow)));
511 const auto start_code_end = styled_dummy.find(
' ');
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);
517 buffer.append(start_code);
518 fmt::vformat_to(std::back_inserter(buffer), fmt, fmt::make_format_args(args...));
519 buffer.append(end_code);
521 s_ClientLogger->info(std::string_view(buffer.data(), buffer.size()));
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)) {
529 fmt::memory_buffer buffer;
531 for (
const char* tag : tags) {
532 fmt::format_to(std::back_inserter(buffer),
"{}", fmt::styled(fmt::format(
"[{}]", tag), fmt::fg(fmt::color::yellow)));
535 buffer.push_back(
' ');
537 const auto styled_dummy = fmt::format(
"{}", fmt::styled(
" ", fmt::fg(fmt::color::orange)));
538 const auto start_code_end = styled_dummy.find(
' ');
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);
544 buffer.append(start_code);
545 fmt::vformat_to(std::back_inserter(buffer), fmt, fmt::make_format_args(args...));
546 buffer.append(end_code);
548 s_ClientLogger->warn(std::string_view(buffer.data(), buffer.size()));
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)) {
556 fmt::memory_buffer buffer;
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)));
562 buffer.push_back(
' ');
564 const auto styled_dummy = fmt::format(
"{}", fmt::styled(
" ", fmt::fg(fmt::color::violet)));
565 const auto start_code_end = styled_dummy.find(
' ');
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);
571 buffer.append(start_code);
572 fmt::vformat_to(std::back_inserter(buffer), fmt, fmt::make_format_args(args...));
573 buffer.append(end_code);
575 s_ClientLogger->error(std::string_view(buffer.data(), buffer.size()));
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)) {
583 fmt::memory_buffer buffer;
585 for (
const char* tag : tags) {
586 fmt::format_to(std::back_inserter(buffer),
"{}", fmt::styled(fmt::format(
"[{}]", tag), fmt::bg(fmt::color::red)));
589 buffer.push_back(
' ');
591 const auto styled_dummy = fmt::format(
"{}", fmt::styled(
" ", fmt::bg(fmt::color::red)));
592 const auto start_code_end = styled_dummy.find(
' ');
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);
598 buffer.append(start_code);
599 fmt::vformat_to(std::back_inserter(buffer), fmt, fmt::make_format_args(args...));
600 buffer.append(end_code);
602 s_ClientLogger->critical(std::string_view(buffer.data(), buffer.size()));
608 template<
typename... Args>
609 static void CoreLogTrace(
const fmt::format_string<Args...>& fmt, Args&&... args) {
610 fmt::memory_buffer buffer;
612 const auto styled_dummy = fmt::format(
"{}", fmt::styled(
" ", fmt::fg(fmt::color::light_cyan)));
613 const auto start_code_end = styled_dummy.find(
' ');
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);
619 buffer.append(start_code);
620 fmt::vformat_to(std::back_inserter(buffer), fmt, fmt::make_format_args(args...));
621 buffer.append(end_code);
623 s_CoreLogger->trace(std::string_view(buffer.data(), buffer.size()));
627 template<
typename... Args>
628 static void CoreLogDebug(
const fmt::format_string<Args...>& fmt, Args&&... args) {
629 fmt::memory_buffer buffer;
631 const auto styled_dummy = fmt::format(
"{}", fmt::styled(
" ", fmt::fg(fmt::color::royal_blue)));
632 const auto start_code_end = styled_dummy.find(
' ');
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);
638 buffer.append(start_code);
639 fmt::vformat_to(std::back_inserter(buffer), fmt, fmt::make_format_args(args...));
640 buffer.append(end_code);
642 s_CoreLogger->debug(std::string_view(buffer.data(), buffer.size()));
646 template<
typename... Args>
647 static void CoreLogInfo(
const fmt::format_string<Args...>& fmt, Args&&... args) {
648 fmt::memory_buffer buffer;
650 const auto styled_dummy = fmt::format(
"{}", fmt::styled(
" ", fmt::fg(fmt::color::green_yellow)));
651 const auto start_code_end = styled_dummy.find(
' ');
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);
657 buffer.append(start_code);
658 fmt::vformat_to(std::back_inserter(buffer), fmt, fmt::make_format_args(args...));
659 buffer.append(end_code);
661 s_CoreLogger->info(std::string_view(buffer.data(), buffer.size()));
665 template<
typename... Args>
666 static void CoreLogWarn(
const fmt::format_string<Args...>& fmt, Args&&... args) {
667 fmt::memory_buffer buffer;
669 const auto styled_dummy = fmt::format(
"{}", fmt::styled(
" ", fmt::fg(fmt::color::orange)));
670 const auto start_code_end = styled_dummy.find(
' ');
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);
676 buffer.append(start_code);
677 fmt::vformat_to(std::back_inserter(buffer), fmt, fmt::make_format_args(args...));
678 buffer.append(end_code);
680 s_CoreLogger->warn(std::string_view(buffer.data(), buffer.size()));
683 template<
typename... Args>
684 static void CoreLogError(
const fmt::format_string<Args...>& fmt, Args&&... args) {
685 fmt::memory_buffer buffer;
687 const auto styled_dummy = fmt::format(
"{}", fmt::styled(
" ", fmt::fg(fmt::color::violet)));
688 const auto start_code_end = styled_dummy.find(
' ');
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);
694 buffer.append(start_code);
695 fmt::vformat_to(std::back_inserter(buffer), fmt, fmt::make_format_args(args...));
696 buffer.append(end_code);
698 s_CoreLogger->error(std::string_view(buffer.data(), buffer.size()));
701 template<
typename... Args>
702 static void CoreLogFatal(
const fmt::format_string<Args...>& fmt, Args&&... args) {
703 fmt::memory_buffer buffer;
705 const auto styled_dummy = fmt::format(
"{}", fmt::styled(
" ", fmt::bg(fmt::color::red)));
706 const auto start_code_end = styled_dummy.find(
' ');
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);
712 buffer.append(start_code);
713 fmt::vformat_to(std::back_inserter(buffer), fmt, fmt::make_format_args(args...));
714 buffer.append(end_code);
716 s_CoreLogger->critical(std::string_view(buffer.data(), buffer.size()));
721 template<
typename... Args>
722 static void ClientLogTrace(
const fmt::format_string<Args...>& fmt, Args&&... args) {
723 fmt::memory_buffer buffer;
725 const auto styled_dummy = fmt::format(
"{}", fmt::styled(
" ", fmt::fg(fmt::color::light_cyan)));
726 const auto start_code_end = styled_dummy.find(
' ');
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);
732 buffer.append(start_code);
733 fmt::vformat_to(std::back_inserter(buffer), fmt, fmt::make_format_args(args...));
734 buffer.append(end_code);
736 s_ClientLogger->trace(std::string_view(buffer.data(), buffer.size()));
739 template<
typename... Args>
740 static void ClientLogDebug(
const fmt::format_string<Args...>& fmt, Args&&... args) {
741 fmt::memory_buffer buffer;
743 const auto styled_dummy = fmt::format(
"{}", fmt::styled(
" ", fmt::fg(fmt::color::royal_blue)));
744 const auto start_code_end = styled_dummy.find(
' ');
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);
750 buffer.append(start_code);
751 fmt::vformat_to(std::back_inserter(buffer), fmt, fmt::make_format_args(args...));
752 buffer.append(end_code);
754 s_ClientLogger->debug(std::string_view(buffer.data(), buffer.size()));
757 template<
typename... Args>
758 static void ClientLogInfo(
const fmt::format_string<Args...>& fmt, Args&&... args) {
759 fmt::memory_buffer buffer;
761 const auto styled_dummy = fmt::format(
"{}", fmt::styled(
" ", fmt::fg(fmt::color::green_yellow)));
762 const auto start_code_end = styled_dummy.find(
' ');
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);
768 buffer.append(start_code);
769 fmt::vformat_to(std::back_inserter(buffer), fmt, fmt::make_format_args(args...));
770 buffer.append(end_code);
772 s_ClientLogger->info(std::string_view(buffer.data(), buffer.size()));
775 template<
typename... Args>
776 static void ClientLogWarn(
const fmt::format_string<Args...>& fmt, Args&&... args) {
777 fmt::memory_buffer buffer;
779 const auto styled_dummy = fmt::format(
"{}", fmt::styled(
" ", fmt::fg(fmt::color::orange)));
780 const auto start_code_end = styled_dummy.find(
' ');
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);
786 buffer.append(start_code);
787 fmt::vformat_to(std::back_inserter(buffer), fmt, fmt::make_format_args(args...));
788 buffer.append(end_code);
790 s_ClientLogger->warn(std::string_view(buffer.data(), buffer.size()));
793 template<
typename... Args>
794 static void ClientLogError(
const fmt::format_string<Args...>& fmt, Args&&... args) {
795 fmt::memory_buffer buffer;
797 const auto styled_dummy = fmt::format(
"{}", fmt::styled(
" ", fmt::fg(fmt::color::violet)));
798 const auto start_code_end = styled_dummy.find(
' ');
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);
804 buffer.append(start_code);
805 fmt::vformat_to(std::back_inserter(buffer), fmt, fmt::make_format_args(args...));
806 buffer.append(end_code);
808 s_ClientLogger->error(std::string_view(buffer.data(), buffer.size()));
811 template<
typename... Args>
812 static void ClientLogFatal(
const fmt::format_string<Args...>& fmt, Args&&... args) {
813 fmt::memory_buffer buffer;
815 const auto styled_dummy = fmt::format(
"{}", fmt::styled(
" ", fmt::bg(fmt::color::red)));
816 const auto start_code_end = styled_dummy.find(
' ');
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);
822 buffer.append(start_code);
823 fmt::vformat_to(std::back_inserter(buffer), fmt, fmt::make_format_args(args...));
824 buffer.append(end_code);
826 s_ClientLogger->critical(std::string_view(buffer.data(), buffer.size()));
831 GetCoreLogger()->debug(
"Sample Text Start Here!!!!!!!!!!!!!!!!!!!!");
898 GetCoreLogger()->debug(
"{}",
ColoredText(
"Sample Text color: light_golden_rod_yellow", fmt::color::light_golden_rod_yellow));
919 GetCoreLogger()->debug(
"{}",
ColoredText(
"Sample Text color: medium_spring_green", fmt::color::medium_spring_green));
976 static bool ShouldCoreLog(std::initializer_list<const char*> tags);
977 static bool ShouldClientLog(std::initializer_list<const char*> tags);
979 static bool s_Initialized;
982 using is_transparent = void;
983 [[nodiscard]]
size_t operator()(
const char* txt)
const {
984 return std::hash<std::string_view>{}(txt);
986 [[nodiscard]]
size_t operator()(
const std::string_view txt)
const {
987 return std::hash<std::string_view>{}(txt);
989 [[nodiscard]]
size_t operator()(
const std::string& txt)
const {
990 return std::hash<std::string_view>{}(txt);
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;
1006#if defined(DEBUG_BUILD) && !defined(DISABLE_LOGGING)
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__)
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__)
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)
1021 #define CORI_CORE_TRACE(...)
1022 #define CORI_CORE_DEBUG(...)
1023 #define CORI_CORE_INFO(...)
1025 #define CORI_CORE_TRACE_TAGGED(...)
1026 #define CORI_CORE_DEBUG_TAGGED(...)
1027 #define CORI_CORE_INFO_TAGGED(...)
1029 #define CORI_CORE_ASSERT(x, ...)
1030 #define CORI_CORE_VERIFY(x, ...) (!x)
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__)
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__)
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())
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())
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__)
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__)
const std::string CORI_SECOND_LINE_SPACING
Logger is the first thing that is initialized during startup. Does console and file logging.
static void EnableClientTag(const char *tag)
Enables the logging of a specific client tag.
static auto HighlightedText(const T &text, const fmt::color c, const fmt::text_style s=fmt::text_style{})
static void ClientLogDebug(const fmt::format_string< Args... > &fmt, Args &&... args)
static void CoreLogError(const fmt::format_string< Args... > &fmt, Args &&... args)
static void CoreLogFatal(const fmt::format_string< Args... > &fmt, Args &&... args)
static void EnableClientTags(const std::initializer_list< const char * > tags)
Same as EnableClientTag but enables multiple tags at once.
static void CoreLogTraceTagged(const std::initializer_list< const char * > tags, const fmt::format_string< Args... > &fmt, Args &&... args)
static void CoreLogWarnTagged(const std::initializer_list< const char * > tags, const fmt::format_string< Args... > &fmt, Args &&... args)
static void ClearCoreTagFilter()
Clears the core tag filter, all tags that were disabled become enabled again as a result.
static void ClientLogTrace(const fmt::format_string< Args... > &fmt, Args &&... args)
static void SampleColors()
static bool IsClientTagDisabled(const char *tag)
Checks if a specific client tag is enabled.
static void ClientLogFatal(const fmt::format_string< Args... > &fmt, Args &&... args)
static void SetClientLogLevel(LogLevel level)
static void CoreLogDebugTagged(const std::initializer_list< const char * > tags, const fmt::format_string< Args... > &fmt, Args &&... args)
static auto ColoredText(const T &text, const fmt::color c, const fmt::text_style s=fmt::text_style{})
static std::shared_ptr< spdlog::logger > & GetClientLogger()
static void EnableCoreTags(const std::initializer_list< const char * > tags)
Same as EnableCoreTag but enables multiple tags at once.
static void CoreLogDebug(const fmt::format_string< Args... > &fmt, Args &&... args)
static void CoreLogFatalTagged(const std::initializer_list< const char * > tags, const fmt::format_string< Args... > &fmt, Args &&... args)
static void CoreLogInfo(const fmt::format_string< Args... > &fmt, Args &&... args)
static void DisableCoreTags(const std::initializer_list< const char * > tags)
Same as DisableCoreTag but disables multiple tags at once.
static void DisableCoreTag(const char *tag)
Disables the logging of a specific core tag.
static std::shared_ptr< spdlog::logger > & GetCoreLogger()
static void ClientLogInfo(const fmt::format_string< Args... > &fmt, Args &&... args)
static void ClientLogFatalTagged(const std::initializer_list< const char * > tags, const fmt::format_string< Args... > &fmt, Args &&... args)
static void ClientLogTraceTagged(const std::initializer_list< const char * > tags, const fmt::format_string< Args... > &fmt, Args &&... args)
static void CoreLogErrorTagged(const std::initializer_list< const char * > tags, const fmt::format_string< Args... > &fmt, Args &&... args)
static void ClientLogErrorTagged(const std::initializer_list< const char * > tags, const fmt::format_string< Args... > &fmt, Args &&... args)
static std::vector< std::string > GetClientInactiveTags()
Gies a list of all currently disabled client tags.
static void CoreLogInfoTagged(const std::initializer_list< const char * > tags, const fmt::format_string< Args... > &fmt, Args &&... args)
static void SetCoreLogLevel(LogLevel level)
static void CoreLogWarn(const fmt::format_string< Args... > &fmt, Args &&... args)
static std::vector< std::string > GetCoreInactiveTags()
Gies a list of all currently disabled core tags.
static void ClearClientTagFilter()
Clears the client tag filter, all tags that were disabled become enabled again as a result.
static void ClientLogWarnTagged(const std::initializer_list< const char * > tags, const fmt::format_string< Args... > &fmt, Args &&... args)
static void ClientLogError(const fmt::format_string< Args... > &fmt, Args &&... args)
static void ClientLogInfoTagged(const std::initializer_list< const char * > tags, const fmt::format_string< Args... > &fmt, Args &&... args)
static void CoreLogTrace(const fmt::format_string< Args... > &fmt, Args &&... args)
static void ClientLogDebugTagged(const std::initializer_list< const char * > tags, const fmt::format_string< Args... > &fmt, Args &&... args)
static void EnableVirtualTerminalProcessing()
static void Init(bool async, bool fileWrite)
static void DisableClientTag(const char *tag)
Disables the logging of a specific core tag.
static std::string BoolAlpha(const bool b)
static void EnableCoreTag(const char *tag)
Enables the logging of a specific core tag.
static void ClientLogWarn(const fmt::format_string< Args... > &fmt, Args &&... args)
static bool IsCoreTagDisabled(const char *tag)
Checks if a specific core tag is enabled.
static void DisableClientTags(const std::initializer_list< const char * > tags)
Same as DisableClientTag but disables multiple tags at once.