diff options
author | Bo Hu <bohu@google.com> | 2024-01-05 14:30:45 -0800 |
---|---|---|
committer | Bo Hu <bohu@google.com> | 2024-01-05 22:34:55 +0000 |
commit | e45570cebe9933b75a7a4bd631aaa007125090f3 (patch) | |
tree | 3dbb69d0660ac253dbd8f85756c93905fd3f097e | |
parent | caf5a079f321b6c60ab7b4bf6e5516378c6a7b37 (diff) | |
download | aemu-e45570cebe9933b75a7a4bd631aaa007125090f3.tar.gz |
log: fix garbage letters in logging output
Change the implementation to send the logger
just a simple string that already has evertying to
log about.
Bug: 318694779
Change-Id: I09b5e655fd79f4e1fdc2883a7e1a38fe0a8819cf
-rw-r--r-- | host-common/logging.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/host-common/logging.cpp b/host-common/logging.cpp index 395169b..0ed0c1f 100644 --- a/host-common/logging.cpp +++ b/host-common/logging.cpp @@ -127,15 +127,15 @@ void OutputLog(FILE* stream, char severity, const char* file, unsigned int line, // Output the actual log message and newline va_list args; va_start(args, format); + char temp[2048]; + int ret = vsnprintf(temp, sizeof(temp), format, args); + temp[sizeof(temp) - 1] = 0; + if (logger) { - logger(format, args); + logger("%s\n", temp); } else { - vfprintf(stream, format, args); + fprintf(stream, "%s\n", temp); } va_end(args); - if (logger) { - logger("\n"); - } else { - fprintf(stream, "\n"); - } + } |