Skip to content

User defined collapsable substrings #171

@bvaughn

Description

@bvaughn

console.error hides stack traces by default, showing only the user-logged errors string:

Console error expand/collapse

This is great because it reduces clutter in the console and makes it easier to scan for a particular message before digging in.

It would be fantastic if the console API exposed a similar opt-in behavior to developers (particularly framework developers) enabling us to define collapsable substrings within a logged message.

As just one example- React could make immediate use of this with our "component stacks" feature. A React DEV warning may currently look something like this:

Warning: Each child in a list should have a unique "key" prop.

Check the render method of List. See https://fb.me/react-warning-keys for more information.
in ListItem (at List.js:20)
in List (at Example.js:7)
in Example

With an API like the one I'm describing, maybe it could instead look like this.

Warning: Each child in a list should have a unique "key" prop.

▸ Check the render method of List.

See https://fb.me/react-warning-keys for more information.

Even if an API like this was limited to only allow for one collapsable string at the end, this would still be an improvement for e.g. large "component stacks"

Warning: Each child in a list should have a unique "key" prop.

See https://fb.me/react-warning-keys for more information.

▸ Check the render method of List.

Doesn't groupCollapsed do this?

groupCollapsed provides some similar functionality:
Console group collapsed toggle

Unfortunately groupCollapsed has a major downside: group logs can never be filtered from a console, which makes them more expensive/noisy.
Console filtering and groups

This feature request is loosely related to #163.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions