Reputation: 3044
For a along time if I did console.trace(123)
- the trace was collapsed. At some point Chrome released a new version, and since then it is always expanded. What can I do to make it appear collapsed?
Upvotes: 5
Views: 627
Reputation: 1932
These is a better workaround now. So they don't plan on fixing it.
https://bugs.chromium.org/p/chromium/issues/detail?id=677929
https://bugs.chromium.org/p/chromium/issues/detail?id=697203
Comment 11 by [email protected], Apr 13 (5 days ago) ⚐
Workaround above always outputs bold text and doesn't support css. Here's a slightly better slightly better polyfil:
if(window.console && console.trace) { var oldTrace = console.trace; console.trace = function(msg, css) { msg = msg && String(msg) || 'trace'; if (!msg.startsWith('%c')) { msg = '%c' + msg; css = 'font-weight: normal;'; } else { css = 'font-weight: normal; ' + String(css || ''); } console.groupCollapsed(msg, css); oldTrace.apply(this); console.groupEnd(); } }
Testing it with:
console.trace('testest'); console.trace('%ctestest', 'color: #F00'); console.trace('%ctestest', 'color: #F00; font-weight: bold;'); console.trace(new RegExp(), new RegExp());
works as expected.
Upvotes: 2
Reputation: 133
This is a bug: https://bugs.chromium.org/p/chromium/issues/detail?id=677929
The workaround I'm aware of is to use console.error instead.
Upvotes: 0