We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using Log.d(xx) to output logs on my Android device does not show up on the console.
I tried to solve this problem and found that I need to modify the log output in LogcatWriter
override fun log(severity: Severity, message: String, tag: String, throwable: Throwable?) { val formattedMessage = messageStringFormatter.formatMessage(null, null, Message(message)) try { if(throwable == null){ when(severity){ Severity.Verbose -> Log.v(tag, formattedMessage) Severity.Debug -> Log.d(tag, formattedMessage) Severity.Info -> Log.i(tag, formattedMessage) Severity.Warn -> Log.w(tag, formattedMessage) Severity.Error -> Log.e(tag, formattedMessage) Severity.Assert -> Log.wtf(tag, formattedMessage) } }else{ when(severity){ Severity.Verbose -> Log.v(tag, formattedMessage, throwable) Severity.Debug -> Log.d(tag, formattedMessage, throwable) Severity.Info -> Log.i(tag, formattedMessage, throwable) Severity.Warn -> Log.w(tag, formattedMessage, throwable) Severity.Error -> Log.e(tag, formattedMessage, throwable) Severity.Assert -> Log.wtf(tag, formattedMessage, throwable) } } } catch (e: Exception) { testWriter.log(severity, message, tag, throwable) } }
replace with
private fun getSeverity(severity: Severity) = when (severity) { Severity.Verbose -> Log.VERBOSE Severity.Debug -> Log.DEBUG Severity.Info -> Log.INFO Severity.Warn -> Log.WARN Severity.Error -> Log.ERROR Severity.Assert -> Log.ASSERT } override fun log(severity: Severity, message: String, tag: String, throwable: Throwable?) { val formattedMessage = messageStringFormatter.formatMessage(null, null, Message(message)) try { // 使用 Log.println 解决部分设备无法输出debug日志问题 val stackTraceString = Log.getStackTraceString(throwable) Log.println( getSeverity(severity), tag, if (stackTraceString.isEmpty()) { formattedMessage } else { formattedMessage + '\n' + stackTraceString } ) } catch (e: Exception) { testWriter.log(severity, message, tag, throwable) } }
Use Log.println to output logs
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Using Log.d(xx) to output logs on my Android device does not show up on the console.
I tried to solve this problem and found that I need to modify the log output in LogcatWriter
replace with
Use Log.println to output logs
The text was updated successfully, but these errors were encountered: