可以利用hilog封装log工具类检查日志长度,超出长度就分段打印,如:class MyLog { static e(logTag: string, content: string) { const maxSize = 1024; if (content.length <= maxSize) { // 长度小于等于限制直接打印 hilog.error(0xFF00, logTag, '%{public}s', content); } else { while (content.length > maxSize) { // 循环分段打印 let logContent = content.substring(0, maxSize); content = content.replace(logContent, ''); hilog.error(0xFF00, logTag, '%{public}s', logContent); // 打印剩余日志 } } } } aboutToAppear(): void { MyLog.e('test', this.waitingDecryptString); }Hilog日志最长支持4096 个字节(包含结束符)参考文档链接: https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-hilog-V5
可以利用hilog封装log工具类检查日志长度,超出长度就分段打印,如:
Hilog日志最长支持4096 个字节(包含结束符)
参考文档链接: https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-hilog-V5