javascript – IE11在控制台中截断字符串

前端之家收集整理的这篇文章主要介绍了javascript – IE11在控制台中截断字符串前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个字符串可能是20或30行,我想输出到控制台所有在一个console.log调用.这在Chrome中效果非常好,但IE11会在控制台中截断大约一半的字符串.任何方式来防止这种情况?字符串是这样的:
-----------------------------------------
Wed Jan 7 20:41:16 GMT-0700 2015 530d8aa855df0c2d269a5a5853a47a049c52c9d83a2d71d9
-----------------------------------------
41:17:181 - Initiating recording...
41:17:233 - Creating NetStream...
41:17:240 - NetStream created.
41:17:240 - Recording ready.
-----------------------------------------
Wed Jan 7 20:41:16 GMT-0700 2015 NetConnectionQueue - rtmp://AMS2alt.commercialtribe.net/recorder/530d8aa855df0c2d269a5a5853a47a049c52c9d83a2d71d9
-----------------------------------------
41:16:867 - Initializing...
41:16:868 - Creating negotiator...
41:17:175 - Connection success: rtmp://AMS2alt.commercialtribe.net:1935/recorder/530d8aa855df0c2d269a5a5853a47a049c52c9d83a2d71d9
41:17:175 - Connection added to queue.
41:17:182 - Connection request recieved...
41:17:183 - Connection request fulfilled.
41:17:452 - Connection success: rtmp://AMS2alt.commercialtribe.net:1935/recorder/530d8aa855df0c2d269a5a5853a47a049c52c9d83a2d71d9
41:17:452 - Connection added to queue.
41:18:503 - -----------------------------------------
Wed Jan 7 20:41:16 GMT-0700 2015 NetNegotiator Log
-----------------------------------------
41:16:890 - Attempting: rtmp://AMS2alt.commercialtribe.net:1935/recorder/530d8aa855df0c2d269a5a5853a47a049c52c9d83a2d71d9
41:17:174 - Negotiator reset
41:17:194 - Attempting: rtmp://AMS2alt.commercialtribe.net:1935/recorder/530d8aa855df0c2d269a5a5853a47a049c52c9d83a2d71d9
41:17:282 - Attempting: rtmp://AMS2alt.commercialtribe.net:443/recorder/530d8aa855df0c2d269a5a5853a47a049c52c9d83a2d71d9
41:17:339 - Attempting: rtmp://AMS2alt.commercialtribe.net:80/recorder/530d8aa855df0c2d269a5a5853a47a049c52c9d83a2d71d9
41:17:400 - Attempting: rtmpt://AMS2alt.commercialtribe.net:1935/recorder/530d8aa855df0c2d269a5a5853a47a049c52c9d83a2d71d9
41:17:451 - NetConnection attempt Failed: rtmp://AMS2alt.commercialtribe.net:443/recorder/530d8aa855df0c2d269a5a5853a47a049c52c9d83a2d71d9
41:17:452 - Negotiator reset

解决方法

单个消息的1024个字符的限制并不完全不合理.即使是这样,IE也没有办法改变这个限制.

出于好奇,为什么这个大块而不是个人调用console.log()与console.group()分组?

console.group("Wed Jan 7 20:41:16 GMT-0700 2015 530d8aa855df0c2d269a5a5853a47a049c52c9d83a2d71d9");
console.log("41:17:181 - Initiating recording...");
console.log("41:17:233 - Creating NetStream...");
console.log("41:17:240 - NetStream created.");
console.log("41:17:240 - Recording ready.");
console.groupEnd();
console.group("Wed Jan 7 20:41:16 GMT-0700 2015 NetConnectionQueue - rtmp://AMS2alt.commercialtribe.net/recorder/530d8aa855df0c2d269a5a5853a47a049c52c9d83a2d71d9");
console.log("41:16:867 - Initializing...");
console.log("41:16:868 - Creating negotiator...");
console.log("41:17:175 - Connection success: rtmp://AMS2alt.commercialtribe.net:1935/recorder/530d8aa855df0c2d269a5a5853a47a049c52c9d83a2d71d9");
console.log("41:17:175 - Connection added to queue.");
console.log("41:17:182 - Connection request recieved...");
console.log("41:17:183 - Connection request fulfilled.");
console.log("41:17:452 - Connection success: rtmp://AMS2alt.commercialtribe.net:1935/recorder/530d8aa855df0c2d269a5a5853a47a049c52c9d83a2d71d9");
console.log("41:17:452 - Connection added to queue.");
console.groupEnd();
console.group("Wed Jan 7 20:41:16 GMT-0700 2015 NetNegotiator Log");
console.log("41:16:890 - Attempting: rtmp://AMS2alt.commercialtribe.net:1935/recorder/530d8aa855df0c2d269a5a5853a47a049c52c9d83a2d71d9");
console.log("41:17:174 - Negotiator reset");
console.log("41:17:194 - Attempting: rtmp://AMS2alt.commercialtribe.net:1935/recorder/530d8aa855df0c2d269a5a5853a47a049c52c9d83a2d71d9");
console.log("41:17:282 - Attempting: rtmp://AMS2alt.commercialtribe.net:443/recorder/530d8aa855df0c2d269a5a5853a47a049c52c9d83a2d71d9");
console.log("41:17:339 - Attempting: rtmp://AMS2alt.commercialtribe.net:80/recorder/530d8aa855df0c2d269a5a5853a47a049c52c9d83a2d71d9");
console.log("41:17:400 - Attempting: rtmpt://AMS2alt.commercialtribe.net:1935/recorder/530d8aa855df0c2d269a5a5853a47a049c52c9d83a2d71d9");
console.log("41:17:451 - NetConnection attempt Failed: rtmp://AMS2alt.commercialtribe.net:443/recorder/530d8aa855df0c2d269a5a5853a47a049c52c9d83a2d71d9");
console.log("41:17:452 - Negotiator reset");
console.groupEnd();

如果邮件被接收为一个大字符串,那么您肯定可以分析它并单独记录每一行,即:

msg.split("\n").forEach(line => console.log(line)); // should probably use a *real* parser
原文链接:https://www.f2er.com/js/150728.html

猜你在找的JavaScript相关文章