如何显示长消息在logcat中 [英] How to display long messages in logcat

查看:111
本文介绍了如何显示长消息在logcat中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在logcat中显示长消息。如果消息的长度超过1000个字符,它就会被折断。

I am trying to display long message on logcat. If the length of message is more than 1000 characters, it gets broken.

什么机制来显示长信息的全部字符的logcat?

What is the mechanism to show all characters of long message in logcat?

推荐答案

如果是的logcat封盖的长度1000,那么可以拆分要记录与String.subString(),并在片记录它的字符串。例如:

If logcat is capping the length at 1000 then you can split the string you want to log with String.subString() and log it in pieces. For example:

int maxLogSize = 1000;
for(int i = 0; i <= veryLongString.length() / maxLogSize; i++) {
    int start = i * maxLogSize;
    int end = (i+1) * maxLogSize;
    end = end > veryLongString.length() ? veryLongString.length() : end;
    Log.v(TAG, veryLongString.substring(start, end));
}

这篇关于如何显示长消息在logcat中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆