I am trying to display long message on logcat. If the length of message is more than 1000 characters, it gets broken.
What is the mechanism to show all characters o
if print json string, can use code below
@JvmStatic
fun j(level: Int, tag: String? = null, msg: String) {
if (debug) {
if (TextUtils.isEmpty(msg)) {
p(level, tag, msg)
} else {
val message: String
message = try {
when {
msg.startsWith("{") -> {
val jsonObject = JSONObject(msg)
jsonObject.toString(4)
}
msg.startsWith("[") -> {
val jsonArray = JSONArray(msg)
jsonArray.toString(4)
}
else -> msg
}
} catch (e: JSONException) {
e.printStackTrace()
msg
}
p(level, tag, "╔═══════════════════════════════════════════════════════════════════════════════════════", false)
val lines = message.split(LINE_SEPARATOR.toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
for (line in lines) {
p(level, tag, "║ $line", false)
}
p(level, tag, "╚═══════════════════════════════════════════════════════════════════════════════════════", false)
}
}
}
full code
CXLogUtil.j("json-tag","{}")