-
Notifications
You must be signed in to change notification settings - Fork 198
feat: add support for consola.group
& consola.groupEnd
#374
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
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
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. 🚀 New features to boost your workflow:
|
@@ -91,6 +95,12 @@ export const LogTypes: Record<LogType, Partial<LogObject>> = { | |||
log: { | |||
level: LogLevels.log, | |||
}, | |||
group: { |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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 samelogObj
@@ -21,6 +21,8 @@ const queue: any[] = []; | |||
export class Consola { | |||
options: ConsolaOptions; | |||
|
|||
private groupIndentionLevel = 0; |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
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 ![]() |
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? |
resolves #184
Preview:
