aboutsummaryrefslogtreecommitdiff
path: root/src/common/Logger.cpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-09-14 22:10:02 +0800
committercrupest <crupest@outlook.com>2021-09-14 22:10:02 +0800
commit46d4838ac8ff1bd8658b57cf4ebb4438e396fce8 (patch)
treef1e04c19630c7f42ad57618e9a2d7cf5ea4d31c1 /src/common/Logger.cpp
parent9bc202a2e1664df3e3c148abfe90a90501bc1650 (diff)
downloadcru-46d4838ac8ff1bd8658b57cf4ebb4438e396fce8.tar.gz
cru-46d4838ac8ff1bd8658b57cf4ebb4438e396fce8.tar.bz2
cru-46d4838ac8ff1bd8658b57cf4ebb4438e396fce8.zip
...
Diffstat (limited to 'src/common/Logger.cpp')
-rw-r--r--src/common/Logger.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/common/Logger.cpp b/src/common/Logger.cpp
index af1dd692..e77e8a85 100644
--- a/src/common/Logger.cpp
+++ b/src/common/Logger.cpp
@@ -30,7 +30,7 @@ void Logger::RemoveSource(ILogSource *source) {
}
namespace {
-std::u16string_view LogLevelToString(LogLevel level) {
+String LogLevelToString(LogLevel level) {
switch (level) {
case LogLevel::Debug:
return u"DEBUG";
@@ -45,36 +45,35 @@ std::u16string_view LogLevelToString(LogLevel level) {
}
}
-std::u16string GetLogTime() {
+String GetLogTime() {
auto time = std::time(nullptr);
auto calendar = std::localtime(&time);
- return fmt::format(u"{}:{}:{}", calendar->tm_hour, calendar->tm_min,
- calendar->tm_sec);
+ return Format(u"{}:{}:{}", calendar->tm_hour, calendar->tm_min,
+ calendar->tm_sec);
}
} // namespace
-void Logger::Log(LogLevel level, std::u16string_view s) {
+void Logger::Log(LogLevel level, const String &message) {
#ifndef CRU_DEBUG
if (level == LogLevel::Debug) {
return;
}
#endif
for (const auto &source : sources_) {
- source->Write(level, fmt::format(u"[{}] {}: {}\n", GetLogTime(),
- LogLevelToString(level), s));
+ source->Write(level, Format(u"[{}] {}: {}\n", GetLogTime(),
+ LogLevelToString(level), message));
}
}
-void Logger::Log(LogLevel level, std::u16string_view tag,
- std::u16string_view s) {
+void Logger::Log(LogLevel level, const String &tag, const String &message) {
#ifndef CRU_DEBUG
if (level == LogLevel::Debug) {
return;
}
#endif
for (const auto &source : sources_) {
- source->Write(level, fmt::format(u"[{}] {} {}: {}\n", GetLogTime(),
- LogLevelToString(level), tag, s));
+ source->Write(level, Format(u"[{}] {} {}: {}\n", GetLogTime(),
+ LogLevelToString(level), tag, message));
}
}
} // namespace cru::log