New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 697203 link

Starred by 3 users

Issue metadata

Status: WontFix
Owner: ----
Closed: Mar 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 2
Type: Bug



Sign in to add a comment

console.trace() expands automatically resulting in console bloat

Reported by je...@trybaker.com, Feb 28 2017

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36

Steps to reproduce the problem:
1. add console.trace() to any method in your javascript
2. view console and see it is already expanded

What is the expected behavior?
To print the console.trace with a caret for expanding

What went wrong?
it auto expands

Did this work before? N/A 

Chrome version: 56.0.2924.87  Channel: stable
OS Version: OS X 10.11.6
Flash Version: Shockwave Flash 24.0 r0

Was this an intended feature update? It's quite frustrating to work with.

 

Comment 1 by woxxom@gmail.com, Feb 28 2017

Use console.groupCollapsed [1]:

function trace(msg) {
    console.groupCollapsed(msg || 'trace');
    console.trace();
    console.groupEnd();
}

On the other hand, it might be nice if console.trace accepted a second boolean parameter to control the initial state: console.trace(object, showCollapsed)

  [1]: https://developers.google.com/web/tools/chrome-devtools/console/console-reference#consolegroupcollapsedobject_object

Comment 2 by je...@trybaker.com, Feb 28 2017

Thank you for the workaround in the meantime.
Cc: kavvaru@chromium.org
Labels: Needs-Feedback
jesse@ Thanks for the issue.

Could you please provide us any sample test file or URL to triage the issue from test team end.

Thanks,

Comment 4 by woxxom@gmail.com, Mar 1 2017

kavvaru@, open devtools and run "console.trace()" without quotes in the console: the output is expanded (there is a triangle button to toggle the state). This becomes a nuisance when each trace contains 10-50 rows (typical case for the modern javascript frameworks) and there are many traces shown.
Status: (was: Unconfirmed)
The point of console.trace is that it spams you with the trace. You could use console.warn() that also captures the trace, but does not expand it by default. Would that work?

Comment 6 Deleted

Comment 7 by je...@trybaker.com, Mar 2 2017

Why is the point of it to spam you?

warn will work though. Thank you for the suggestion.

Comment 8 Deleted

Comment 9 by je...@trybaker.com, Mar 2 2017

if(window.console && console.trace) {
    var oldTrace = console.trace;
    console.trace = function(msg) {
        console.groupCollapsed(msg || 'trace');
        oldTrace.apply(this);
        console.groupEnd();
    }
}

Here's a slightly better polyfill for anyone else who wants to still use console.trace();
Status: WontFix
Marking as won't fix due to viable workaround.

Comment 11 by igar...@gmail.com, Apr 13 2018

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.

Sign in to add a comment