Skip to content

Conversation

@kricsleo
Copy link
Member

@kricsleo kricsleo commented Mar 25, 2025

resolves #184

Preview:
image

@codecov
Copy link

codecov bot commented Mar 25, 2025

Codecov Report

Attention: Patch coverage is 30.61224% with 34 lines in your changes missing coverage. Please review.

Project coverage is 29.11%. Comparing base (24c98ce) to head (d536a3e).
Report is 57 commits behind head on main.

Files with missing lines Patch % Lines
examples/group.ts 0.00% 15 Missing and 1 partial ⚠️
src/reporters/basic.ts 7.14% 13 Missing ⚠️
src/consola.ts 50.00% 4 Missing ⚠️
src/reporters/fancy.ts 66.66% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main     #374       +/-   ##
===========================================
- Coverage   61.08%   29.11%   -31.98%     
===========================================
  Files          13       44       +31     
  Lines        1380     1769      +389     
  Branches       58       92       +34     
===========================================
- Hits          843      515      -328     
- Misses        537     1226      +689     
- Partials        0       28       +28     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

log: {
level: LogLevels.log,
},
group: {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

group/groupEnv don't need to be a log type (like consola.prompt they can be standalone consola methods)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Treating them as log types simplifies integration with the existing logic, I suppose 🤔

  • wrap & unwrap
  • reporters can format or process .group message with the same logObj

export class Consola {
options: ConsolaOptions;

private groupIndentionLevel = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am thinking instead of having an integer, we can store group titles, for example, consola.group('building..') can be displayed (or used for interceptors)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The groupIndentionLevel tracks the indentation level since .group can be nested.

If we consider .group as a log type, the current logic can display group titles correctly without further changes.

@kricsleo
Copy link
Member Author

kricsleo commented Mar 26, 2025

I plan to use indentation to display groups, consistent with native behavior. What do you think? 🤔

consola.info('0 - Hello World!')

consola.group('0 - Group')
consola.info('1 - Hello World!')
consola.warn('1 - Hello World!')
consola.error(new Error('1 - Hello World!'))

consola.group('1 - Group')
consola.info('1-1 - Hello World!')
consola.warn('1-1 - Hello World!')
consola.error(new Error('1-1 - Hello World!'))
consola.groupEnd()

consola.info('1 - Hello World!')
consola.warn('1 - Hello World!')
consola.error(new Error('1 - Hello World!'))

consola.groupEnd()

consola.info('0 - Hello World!')

Would this work for you? (vertical line added) @pi0

image

@pi0
Copy link
Member

pi0 commented Mar 26, 2025

Surely we can also use them for indentation (array.length), I am thinking to allow show a vertical line | in left to make it more organized better than what Node.js console does wdyt?

@kricsleo kricsleo marked this pull request as ready for review March 26, 2025 16:36
@gkTim
Copy link

gkTim commented Oct 5, 2025

Any news on this? Would love this feature!
@kricsleo are you still working on this one? Thanks for your effort!

@kricsleo
Copy link
Member Author

I currently leave this PR as it is until more changes are requested.
(And, the author, pi0 might not have enough bandwith for this for now)

@pi0
Copy link
Member

pi0 commented Oct 10, 2025

It is a VERY nice addition and my todo.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for console.group

3 participants