最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to stop Firebug from truncating strings in the console? - Stack Overflow

programmeradmin0浏览0评论

While debugging, I frequently dump strings and arrays to the console. But in some cases, Firebug chops up string values, making it hard to be sure of the result.

For example, this code in the console:

console.log ( [
    "123456789A123456789B123456789C123456789D123456789E123456789F123456789G",
    "123456789A123456789B123456789C123456789D123456789E123456789F123456789G"
] );

Yields:

[ "123456789A123456789B123...89E123456789F123456789G",
  "123456789A123456789B123...89E123456789F123456789G"
]

(Bad!)


A single string is okay. This:

console.log ("123456789A123456789B123456789C123456789D123456789E123456789F123456789G");

Yields:

123456789A123456789B123456789C123456789D123456789E123456789F123456789G

as expected.

But, arrays and objects get shortened.
How do I stop this behavior? Is this a bug? (My Google-Fu has failed, so far.)

While debugging, I frequently dump strings and arrays to the console. But in some cases, Firebug chops up string values, making it hard to be sure of the result.

For example, this code in the console:

console.log ( [
    "123456789A123456789B123456789C123456789D123456789E123456789F123456789G",
    "123456789A123456789B123456789C123456789D123456789E123456789F123456789G"
] );

Yields:

[ "123456789A123456789B123...89E123456789F123456789G",
  "123456789A123456789B123...89E123456789F123456789G"
]

(Bad!)


A single string is okay. This:

console.log ("123456789A123456789B123456789C123456789D123456789E123456789F123456789G");

Yields:

123456789A123456789B123456789C123456789D123456789E123456789F123456789G

as expected.

But, arrays and objects get shortened.
How do I stop this behavior? Is this a bug? (My Google-Fu has failed, so far.)

Share Improve this question asked Sep 28, 2012 at 8:19 Brock AdamsBrock Adams 93.5k23 gold badges240 silver badges304 bronze badges 1
  • possible duplicate of Firebug console shortening strings in array logged? – Ariel Commented Sep 28, 2012 at 8:27
Add a comment  | 

3 Answers 3

Reset to default 9

Okay, after pawing through the list of Firebug Preferences (there's 204 of those, right now, and not in an apparent order), I found stringCropLength.

It defaults to 50, which makes sense, since the test strings were truncated to 123456789A123456789B123...89E123456789F123456789G, which is 49 characters long.

Opening about:config and setting extensions.firebug.stringCropLength to 0, stopped the strings from being truncated!

Note that according to Issue 5898: Introduce different string cropping preferences, this preference might affect a few things (for now). But, so far, I've seen no ill effects from having this set to no "cropping".

Use console.dir instead of console.log - the output has a + near it which lets you expand the string.

Use console.dir("....") function instead of console.log("...") Also u might be intersted to look at firebug preferences

发布评论

评论列表(0)

  1. 暂无评论