aboutsummaryrefslogtreecommitdiff
path: root/include/cru/common
diff options
context:
space:
mode:
Diffstat (limited to 'include/cru/common')
-rw-r--r--include/cru/common/Base.hpp2
-rw-r--r--include/cru/common/Logger.hpp14
-rw-r--r--include/cru/common/String.hpp2
3 files changed, 10 insertions, 8 deletions
diff --git a/include/cru/common/Base.hpp b/include/cru/common/Base.hpp
index 2f76385e..174ac037 100644
--- a/include/cru/common/Base.hpp
+++ b/include/cru/common/Base.hpp
@@ -96,5 +96,5 @@ inline void hash_combine(std::size_t& s, const T& v) {
#define CRU_DEFINE_CLASS_LOG_TAG(tag) \
private: \
- constexpr static std::u16string_view log_tag = tag;
+ constexpr static StringView log_tag = tag;
} // namespace cru
diff --git a/include/cru/common/Logger.hpp b/include/cru/common/Logger.hpp
index 5aea5126..3dabeb91 100644
--- a/include/cru/common/Logger.hpp
+++ b/include/cru/common/Logger.hpp
@@ -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 String& s) = 0;
+ virtual void Write(LogLevel level, StringView 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, const String& message);
- void Log(LogLevel level, const String& tag, const String& message);
+ void Log(LogLevel level, StringView message);
+ void Log(LogLevel level, StringView tag, StringView message);
private:
std::list<std::unique_ptr<ILogSource>> sources_;
@@ -69,7 +69,7 @@ void Error(TArgs&&... args) {
// TODO: Remove argument evaluation in Debug.
template <typename... TArgs>
-void TagDebug([[maybe_unused]] std::u16string_view tag,
+void TagDebug([[maybe_unused]] StringView tag,
[[maybe_unused]] TArgs&&... args) {
#ifdef CRU_DEBUG
Logger::GetInstance()->Log(LogLevel::Debug, tag,
@@ -78,19 +78,19 @@ void TagDebug([[maybe_unused]] std::u16string_view tag,
}
template <typename... TArgs>
-void TagInfo(std::u16string_view tag, TArgs&&... args) {
+void TagInfo(StringView tag, TArgs&&... args) {
Logger::GetInstance()->Log(LogLevel::Info, tag,
Format(std::forward<TArgs>(args)...));
}
template <typename... TArgs>
-void TagWarn(std::u16string_view tag, TArgs&&... args) {
+void TagWarn(StringView tag, TArgs&&... args) {
Logger::GetInstance()->Log(LogLevel::Warn, tag,
Format(std::forward<TArgs>(args)...));
}
template <typename... TArgs>
-void TagError(std::u16string_view tag, TArgs&&... args) {
+void TagError(StringView tag, TArgs&&... args) {
Logger::GetInstance()->Log(LogLevel::Error, tag,
Format(std::forward<TArgs>(args)...));
}
diff --git a/include/cru/common/String.hpp b/include/cru/common/String.hpp
index f407cb60..58abc517 100644
--- a/include/cru/common/String.hpp
+++ b/include/cru/common/String.hpp
@@ -372,6 +372,8 @@ inline void String::append(StringView str) {
}
inline String String::From(StringView str) { return str.ToString(); }
+
+inline String ToString(StringView value) { return value.ToString(); }
} // namespace cru
template <>