|
16 | 16 | /* ===================== */ |
17 | 17 |
|
18 | 18 | #if !__has_include(<format>) |
19 | | - #error "Neko logging Cannot find header <format>" |
| 19 | +#error "Neko logging Cannot find header <format>" |
20 | 20 | #endif |
21 | 21 |
|
22 | | -#include <version> |
23 | 22 | #include <format> |
| 23 | +#include <version> |
24 | 24 |
|
25 | 25 | #if !defined(__cpp_lib_format) || __cpp_lib_format < 201907L |
26 | | - #error "Neko logging requires <format> support" |
| 26 | +#error "Neko logging requires <format> support" |
27 | 27 | #endif |
28 | 28 |
|
29 | 29 | /* ===================== */ |
@@ -145,7 +145,11 @@ namespace neko::log { |
145 | 145 | std::lock_guard<std::mutex> lock(namesMutex); |
146 | 146 | threadNames.clear(); |
147 | 147 | } |
148 | | - } inline threadNameManager; |
| 148 | + } |
| 149 | +#if !defined(NEKO_LOG_ENABLE_MODULE) || (NEKO_LOG_ENABLE_MODULE == false) |
| 150 | + inline |
| 151 | +#endif |
| 152 | + threadNameManager; |
149 | 153 |
|
150 | 154 | /** |
151 | 155 | * @brief Log record structure |
@@ -299,8 +303,8 @@ namespace neko::log { |
299 | 303 | public: |
300 | 304 | explicit ConsoleAppender(std::unique_ptr<IFormatter> formatter = std::make_unique<DefaultFormatter>()) |
301 | 305 | : formatter(std::move(formatter)) { |
302 | | - preOutput(); |
303 | | - } |
| 306 | + preOutput(); |
| 307 | + } |
304 | 308 |
|
305 | 309 | explicit ConsoleAppender(Level level, std::unique_ptr<IFormatter> formatter = std::make_unique<DefaultFormatter>()) |
306 | 310 | : formatter(std::move(formatter)) { |
@@ -595,29 +599,33 @@ namespace neko::log { |
595 | 599 | // === formatted message logging === |
596 | 600 |
|
597 | 601 | template <typename... Args> |
598 | | - void debug(std::format_string<Args...> fmt, const neko::SrcLocInfo &location, Args &&...args) { |
| 602 | + void debug(std::format_string<Args...> fmt, const neko::SrcLocInfo &location, Args &&...args) { |
599 | 603 | auto message = std::format(fmt, std::forward<Args>(args)...); |
600 | 604 | log(Level::Debug, message, location); |
601 | 605 | } |
602 | 606 |
|
603 | 607 | template <typename... Args> |
604 | | - void info(std::format_string<Args...> fmt, const neko::SrcLocInfo &location, Args &&...args) { |
| 608 | + void info(std::format_string<Args...> fmt, const neko::SrcLocInfo &location, Args &&...args) { |
605 | 609 | auto message = std::format(fmt, std::forward<Args>(args)...); |
606 | 610 | log(Level::Info, message, location); |
607 | 611 | } |
608 | 612 |
|
609 | 613 | template <typename... Args> |
610 | | - void warn(std::format_string<Args...> fmt, const neko::SrcLocInfo &location, Args &&...args) { |
| 614 | + void warn(std::format_string<Args...> fmt, const neko::SrcLocInfo &location, Args &&...args) { |
611 | 615 | auto message = std::format(fmt, std::forward<Args>(args)...); |
612 | 616 | log(Level::Warn, message, location); |
613 | 617 | } |
614 | 618 |
|
615 | 619 | template <typename... Args> |
616 | | - void error(std::format_string<Args...> fmt, const neko::SrcLocInfo &location, Args &&...args) { |
| 620 | + void error(std::format_string<Args...> fmt, const neko::SrcLocInfo &location, Args &&...args) { |
617 | 621 | auto message = std::format(fmt, std::forward<Args>(args)...); |
618 | 622 | log(Level::Error, message, location); |
619 | 623 | } |
620 | | - } inline logger; |
| 624 | + } |
| 625 | +#if !defined(NEKO_LOG_ENABLE_MODULE) || (NEKO_LOG_ENABLE_MODULE == false) |
| 626 | + inline |
| 627 | +#endif |
| 628 | + logger; |
621 | 629 |
|
622 | 630 | // === Convenience functions === |
623 | 631 |
|
@@ -697,22 +705,22 @@ namespace neko::log { |
697 | 705 | } |
698 | 706 |
|
699 | 707 | template <typename... Args> |
700 | | - void debug(std::format_string<Args...> fmt, const neko::SrcLocInfo &location, Args &&...args) { |
| 708 | + void debug(std::format_string<Args...> fmt, const neko::SrcLocInfo &location, Args &&...args) { |
701 | 709 | auto message = std::format(fmt, std::forward<Args>(args)...); |
702 | 710 | logger.debug(message, location); |
703 | 711 | } |
704 | 712 | template <typename... Args> |
705 | | - void info(std::format_string<Args...> fmt, const neko::SrcLocInfo &location, Args &&...args) { |
| 713 | + void info(std::format_string<Args...> fmt, const neko::SrcLocInfo &location, Args &&...args) { |
706 | 714 | auto message = std::format(fmt, std::forward<Args>(args)...); |
707 | 715 | logger.info(message, location); |
708 | 716 | } |
709 | 717 | template <typename... Args> |
710 | | - void warn(std::format_string<Args...> fmt, const neko::SrcLocInfo &location, Args &&...args) { |
| 718 | + void warn(std::format_string<Args...> fmt, const neko::SrcLocInfo &location, Args &&...args) { |
711 | 719 | auto message = std::format(fmt, std::forward<Args>(args)...); |
712 | 720 | logger.warn(message, location); |
713 | 721 | } |
714 | 722 | template <typename... Args> |
715 | | - void error(std::format_string<Args...> fmt, const neko::SrcLocInfo &location, Args &&...args) { |
| 723 | + void error(std::format_string<Args...> fmt, const neko::SrcLocInfo &location, Args &&...args) { |
716 | 724 | auto message = std::format(fmt, std::forward<Args>(args)...); |
717 | 725 | logger.error(message, location); |
718 | 726 | } |
|
0 commit comments