Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customizable console.group indentation #32947

Closed
privatenumber opened this issue Apr 20, 2020 · 4 comments
Closed

Customizable console.group indentation #32947

privatenumber opened this issue Apr 20, 2020 · 4 comments
Labels
console Issues and PRs related to the console subsystem. feature request Issues that request new features to be added to Node.js.

Comments

@privatenumber
Copy link
Contributor

privatenumber commented Apr 20, 2020

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);
};
@BridgeAR
Copy link
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.

@BridgeAR BridgeAR added console Issues and PRs related to the console subsystem. feature request Issues that request new features to be added to Node.js. labels Apr 20, 2020
@privatenumber
Copy link
Contributor Author

Yes! ty

@rickyes
Copy link
Contributor

rickyes commented Apr 20, 2020

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

@BridgeAR
Copy link
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).

targos pushed a commit that referenced this issue May 4, 2020
PR-URL: #32964
Fixes: #32947
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
targos pushed a commit that referenced this issue May 7, 2020
PR-URL: #32964
Fixes: #32947
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
targos pushed a commit that referenced this issue May 13, 2020
PR-URL: #32964
Fixes: #32947
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
console Issues and PRs related to the console subsystem. feature request Issues that request new features to be added to Node.js.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants