Skip to content

Commit 355ed72

Browse files
committed
Make Android logcat logging ignore single '\n' log line.
1 parent e7656b8 commit 355ed72

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

src/coreclr/vm/eepolicy.cpp

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -373,42 +373,35 @@ void LogInfoForFatalError(UINT exitCode, LPCWSTR pszMessage, PEXCEPTION_POINTERS
373373

374374
EX_TRY
375375
{
376-
StackSString message;
377376
if (exitCode == (UINT)COR_E_FAILFAST)
378377
{
379-
message.Append(W("Process terminated. "));
378+
PrintToStdErrA("Process terminated.\n");
380379
}
381380
else
382381
{
383-
message.Append(W("Fatal error. "));
382+
PrintToStdErrA("Fatal error.\n");
384383
}
385384

386385
if (errorSource != NULL)
387386
{
388-
message.Append(errorSource);
389-
message.Append(W("\n"));
390-
391-
PrintToStdErrW(message.GetUnicode());
392-
393-
message.Clear();
387+
PrintToStdErrW(errorSource);
388+
PrintToStdErrA("\n");
394389
}
395390

396391
if (pszMessage != NULL)
397392
{
398-
message.Append(pszMessage);
393+
PrintToStdErrW(pszMessage);
394+
PrintToStdErrA("\n");
399395
}
400396
else
401397
{
402398
// If no message was passed in, generate it from the exitCode
403399
InlineSString<256> exitCodeMessage;
404400
GetHRMsg(exitCode, exitCodeMessage);
405-
message.Append(exitCodeMessage);
401+
PrintToStdErrW(exitCodeMessage.GetUnicode());
402+
PrintToStdErrA("\n");
406403
}
407404

408-
message.Append(W("\n"));
409-
410-
PrintToStdErrW(message.GetUnicode());
411-
412405
Thread* pThread = GetThreadNULLOk();
413406
if (pThread && errorSource == NULL)
414407
{

src/native/minipal/log.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ static int android_log_flag(minipal_log_flags flags)
4646

4747
static size_t log_write(minipal_log_flags flags, const char* msg, size_t msg_len)
4848
{
49+
if (msg_len == 1 && msg[0] == '\n')
50+
return 0;
51+
4952
return __android_log_write(android_log_flag(flags), MINIPAL_LOG_RUNTIME_TAG, msg) == 1 ? msg_len : 0;
5053
}
5154

0 commit comments

Comments
 (0)