unjs / consola

๐Ÿจ Elegant Console Logger for Node.js and Browser
Other
6.12k stars 175 forks source link

feat(utils): `formatTree` utility #223

Closed Barbapapazes closed 11 months ago

Barbapapazes commented 1 year ago

๐Ÿ”— Linked issue

โ“ Type of change

๐Ÿ“š Description

Add a logger that display a tree of items. This can be used in Nitro when pages are prerendered.

Supports:

image

๐Ÿ“ Checklist

codecov[bot] commented 1 year ago

Codecov Report

Attention: 54 lines in your changes are missing coverage. Please review.

Comparison is base (7fc69ba) 61.13% compared to head (7e34ab5) 60.13%. Report is 2 commits behind head on main.

:exclamation: Current head 7e34ab5 differs from pull request most recent head af47a87. Consider uploading reports for the commit af47a87 to get more accurate results

Files Patch % Lines
src/utils/tree.ts 40.47% 50 Missing :warning:
src/reporters/fancy.ts 20.00% 4 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #223 +/- ## ========================================== - Coverage 61.13% 60.13% -1.00% ========================================== Files 13 14 +1 Lines 1379 1480 +101 Branches 58 58 ========================================== + Hits 843 890 +47 - Misses 536 590 +54 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

pi0 commented 11 months ago

Thanks for working on this it is a really useful addition! ๐Ÿ”ฅ

I have made a couple of reactors to keep the feature as an opt-in util. Despite normal log levels and also box where formatting for them is optional, with tree, when reporters don't implement it (basic, json, browser, etc) it will lead to and unreadable output. I am thinking to introduce more of formatting utils like this consola/utils subpath so we can easily scale without worrying about this.