diff options
author | crupest <crupest@outlook.com> | 2021-09-14 22:10:02 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-09-14 22:10:02 +0800 |
commit | 46d4838ac8ff1bd8658b57cf4ebb4438e396fce8 (patch) | |
tree | f1e04c19630c7f42ad57618e9a2d7cf5ea4d31c1 /include/cru/common/Logger.hpp | |
parent | 9bc202a2e1664df3e3c148abfe90a90501bc1650 (diff) | |
download | cru-46d4838ac8ff1bd8658b57cf4ebb4438e396fce8.tar.gz cru-46d4838ac8ff1bd8658b57cf4ebb4438e396fce8.tar.bz2 cru-46d4838ac8ff1bd8658b57cf4ebb4438e396fce8.zip |
...
Diffstat (limited to 'include/cru/common/Logger.hpp')
-rw-r--r-- | include/cru/common/Logger.hpp | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/include/cru/common/Logger.hpp b/include/cru/common/Logger.hpp index 239a25cd..5aea5126 100644 --- a/include/cru/common/Logger.hpp +++ b/include/cru/common/Logger.hpp @@ -1,10 +1,10 @@ #pragma once #include "Base.hpp" -#include <fmt/format.h> +#include "String.hpp" + #include <list> #include <memory> -#include <string_view> namespace cru::log { @@ -13,7 +13,7 @@ enum class LogLevel { Debug, Info, Warn, Error }; struct CRU_BASE_API ILogSource : virtual Interface { // Write the string s. LogLevel is just a helper. It has no effect on the // content to write. - virtual void Write(LogLevel level, const std::u16string& s) = 0; + virtual void Write(LogLevel level, const String& s) = 0; }; class CRU_BASE_API Logger : public Object { @@ -33,8 +33,8 @@ class CRU_BASE_API Logger : public Object { void RemoveSource(ILogSource* source); public: - void Log(LogLevel level, std::u16string_view s); - void Log(LogLevel level, std::u16string_view tag, std::u16string_view s); + void Log(LogLevel level, const String& message); + void Log(LogLevel level, const String& tag, const String& message); private: std::list<std::unique_ptr<ILogSource>> sources_; @@ -45,26 +45,26 @@ template <typename... TArgs> void Debug([[maybe_unused]] TArgs&&... args) { #ifdef CRU_DEBUG Logger::GetInstance()->Log(LogLevel::Debug, - fmt::format(std::forward<TArgs>(args)...)); + Format(std::forward<TArgs>(args)...)); #endif } template <typename... TArgs> void Info(TArgs&&... args) { Logger::GetInstance()->Log(LogLevel::Info, - fmt::format(std::forward<TArgs>(args)...)); + Format(std::forward<TArgs>(args)...)); } template <typename... TArgs> void Warn(TArgs&&... args) { Logger::GetInstance()->Log(LogLevel::Warn, - fmt::format(std::forward<TArgs>(args)...)); + Format(std::forward<TArgs>(args)...)); } template <typename... TArgs> void Error(TArgs&&... args) { Logger::GetInstance()->Log(LogLevel::Error, - fmt::format(std::forward<TArgs>(args)...)); + Format(std::forward<TArgs>(args)...)); } // TODO: Remove argument evaluation in Debug. @@ -73,25 +73,25 @@ void TagDebug([[maybe_unused]] std::u16string_view tag, [[maybe_unused]] TArgs&&... args) { #ifdef CRU_DEBUG Logger::GetInstance()->Log(LogLevel::Debug, tag, - fmt::format(std::forward<TArgs>(args)...)); + Format(std::forward<TArgs>(args)...)); #endif } template <typename... TArgs> void TagInfo(std::u16string_view tag, TArgs&&... args) { Logger::GetInstance()->Log(LogLevel::Info, tag, - fmt::format(std::forward<TArgs>(args)...)); + Format(std::forward<TArgs>(args)...)); } template <typename... TArgs> void TagWarn(std::u16string_view tag, TArgs&&... args) { Logger::GetInstance()->Log(LogLevel::Warn, tag, - fmt::format(std::forward<TArgs>(args)...)); + Format(std::forward<TArgs>(args)...)); } template <typename... TArgs> void TagError(std::u16string_view tag, TArgs&&... args) { Logger::GetInstance()->Log(LogLevel::Error, tag, - fmt::format(std::forward<TArgs>(args)...)); + Format(std::forward<TArgs>(args)...)); } } // namespace cru::log |