diff options
Diffstat (limited to 'src/common/logging.cpp')
| -rw-r--r-- | src/common/logging.cpp | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/src/common/logging.cpp b/src/common/logging.cpp index 5915cca862..ed12d52532 100644 --- a/src/common/logging.cpp +++ b/src/common/logging.cpp @@ -329,7 +329,7 @@ struct LogcatBackend : public Backend { } }(); auto const df = GetDirectFormatArgs(entry); - __android_log_print(android_log_priority, "YuzuNative", CCB_PRINTF_FMT, df.time_seconds, df.time_fractional, df.class_name, df.level_name, entry.filename, entry.line_num, entry.function, entry.message); + __android_log_print(android_log_priority, "YuzuNative", "%s %s:%u:%s: %s", df.class_name, entry.filename, entry.line_num, entry.function, entry.message); } void Flush() noexcept override {} }; @@ -428,21 +428,33 @@ void FmtLogMessageImpl(Class log_class, Level log_level, const char* filename, u auto const flush = ::Settings::values.log_flush_line.GetValue(); char buffer[BUFSIZ]; auto result = fmt::vformat_to_n(buffer, sizeof(buffer) - 1, format, args); - buffer[(std::min)(result.size, sizeof(buffer) - 1)] = '\0'; - logging_instance->ForEachBackend([=](Backend& backend) { - backend.Write(Entry{ - .message = buffer, - .message_len = (std::min)(result.size, sizeof(buffer) - 1), - .timestamp = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::steady_clock::now() - logging_instance->time_origin), - .log_class = log_class, - .log_level = log_level, - .filename = TrimSourcePath(filename), - .function = function, - .line_num = line_num, + Entry e{ + .message = nullptr, + .message_len = 0, + .timestamp = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::steady_clock::now() - logging_instance->time_origin), + .log_class = log_class, + .log_level = log_level, + .filename = TrimSourcePath(filename), + .function = function, + .line_num = line_num, + }; + if (result.size <= sizeof(buffer) - 1) { + buffer[(std::min)(result.size, sizeof(buffer) - 1)] = '\0'; + e.message = buffer; + e.message_len = (std::min)(result.size, sizeof(buffer) - 1); + logging_instance->ForEachBackend([=](Backend& backend) { + backend.Write(e); + if (flush) backend.Flush(); }); - if (flush) - backend.Flush(); - }); + } else { + std::string s = fmt::vformat(format, args); + e.message = s.c_str(); + e.message_len = s.size(); + logging_instance->ForEachBackend([=](Backend& backend) { + backend.Write(e); + if (flush) backend.Flush(); + }); + } } } } // namespace Common::Log |
