Skip to content

Customizable console.group indentation #32947

Description

@privatenumber

Is your feature request related to a problem? Please describe.
The indentation width used by console.group is too small for me.

Describe the solution you'd like
Customizable indentation width. Perhaps with a Node flag or env variable as we probably won't want to modify the console.group API.


As a hacky workaround, I'm currently overwriting console.group:

const kGroupIndent = Object.getOwnPropertySymbols(console).find(s => s.description === 'kGroupIndent');
const increaseIndentBy = '  ';
const { group, groupEnd } = console;
console.group = function () {
	group.apply(this, arguments);
	this[kGroupIndent] += increaseIndentBy;
};
console.groupEnd = function () {
	groupEnd.apply(this, arguments);
	this[kGroupIndent] = this[kGroupIndent].slice(0, this[kGroupIndent].length - increaseIndentBy.length);
};

Activity

  1. BridgeAR commented on Apr 20, 2020

    @BridgeAR
    Member

    It would be possible to add an option to the console constructor that allows to modify the indentation. Would this be sufficient? It would not have any impact on the global console in that case.

  2. added
    consoleIssues and PRs related to the console subsystem.
    feature requestIssues requesting new Node.js features.
    on Apr 20, 2020
  3. privatenumber commented on Apr 20, 2020

    @privatenumber
    ContributorAuthor

    Yes! ty

  4. rickyes commented on Apr 20, 2020

    @rickyes
    Contributor

    Maybe use ' '. repeat(n), can I work on this ?

  5. BridgeAR commented on Apr 20, 2020

    @BridgeAR
    Member

    @rickyes please feel free to work on it. The constructor requires a new option (e.g., groupIndentation) and the kGroupIndent has to be changed accordingly (instead of using two spaces as done currently). Probably by adding another symbol property (e.g., kGroupIndentationWidth).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    consoleIssues and PRs related to the console subsystem.feature requestIssues requesting new Node.js features.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions