diff options
| author | lizzie <lizzie@eden-emu.dev> | 2026-08-30 08:24:00 +0200 |
|---|---|---|
| committer | crueter <crueter@eden-emu.dev> | 2026-08-30 08:24:00 +0200 |
| commit | e5b656e3725dc3718e31a4d6d91649801dcdd40b (patch) | |
| tree | f4c225a2bb9f3e019bba3eb50e7720fcbe2be849 /src/common/logging.cpp | |
| parent | 297e797a320f099e376af27a9b7a7159d0f13964 (diff) | |
[common/logging] Fix long logs, remove clutter on Android logcat (#4310)
Signed-off-by: lizzie <lizzie@eden-emu.dev>
- [x] I have read and followed the [Contribution Guidelines](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/CONTRIBUTING.md#code-contributions).
- [x] I have read and followed the [AI Policy](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/docs/policies/AI.md)
- [x] I have read and followed the [Coding Guidelines](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/docs/policies/Coding.md) to the best of my ability.
-------------------
logs normally are like this:
```
08-27 02:58:48.188 12511 4743 W YuzuNative: [18534.062505] Shader <Warning> shader_recompiler/frontend/maxwell/translate/impl/move_special_register.cpp:141:Read: (STUBBED) SR_WSCALEFACTOR_XY
08-27 02:58:48.188 12511 4743 W YuzuNative: [18534.062513] Shader <Warning> shader_recompiler/frontend/maxwell/translate/impl/move_special_register.cpp:144:Read: (STUBBED) SR_WSCALEFACTOR_Z
08-27 02:58:48.188 12511 4743 W YuzuNative: [18534.062520] Shader <Warning> shader_recompiler/frontend/maxwell/translate/impl/vote.cpp:50:VOTE_vtg: (STUBBED) called
08-27 02:58:48.188 12511 4743 W YuzuNative: [18534.062523] Shader <Warning> shader_recompiler/frontend/ir/ir_emitter.cpp:267:GetFlowTest: (STUBBED) FCSM_TR
```
bunch of redundant info imo
instead they should just be
```
08-27 02:58:48.188 12511 4743 W YuzuNative: Shader shader_recompiler/frontend/maxwell/translate/impl/move_special_register.cpp:141:Read: (STUBBED) SR_WSCALEFACTOR_XY
08-27 02:58:48.188 12511 4743 W YuzuNative: Shader shader_recompiler/frontend/maxwell/translate/impl/move_special_register.cpp:144:Read: (STUBBED) SR_WSCALEFACTOR_Z
08-27 02:58:48.188 12511 4743 W YuzuNative: Shader shader_recompiler/frontend/maxwell/translate/impl/vote.cpp:50:VOTE_vtg: (STUBBED) called
08-27 02:58:48.188 12511 4743 W YuzuNative: Shader shader_recompiler/frontend/ir/ir_emitter.cpp:267:GetFlowTest: (STUBBED) FCSM_TR
```
Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4310
Reviewed-by: crueter <crueter@eden-emu.dev>
Reviewed-by: CamilleLaVey <camillelavey99@gmail.com>
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 |
