feat(kit): RFC - Unified Logging API proposal#155
feat(kit): RFC - Unified Logging API proposal#155adriandarian wants to merge 12 commits intovitejs:mainfrom
Conversation
This PR proposes a unified logging API for Vite DevTools to replace scattered console.* calls with a consistent, configurable logging system. Includes: - Logger types and interfaces - Node.js implementation (colored terminal output) - Browser/client implementation (styled console) - Log collector for aggregation (enables Logs panel) - Unit tests (14 passing) - RFC documentation with migration examples Related TODOs: - packages/core/src/client/webcomponents/state/setup-script.ts:20 - packages/core/src/node/host-docks.ts:34
antfu
left a comment
There was a problem hiding this comment.
While I like this idea, I think the current PR is a bit overdone. I think maybe we could use https://github.com/unjs/consola (which handles a lot of the complexity introduced here) and expose it on context.logger, similar to Nuxt Kit: https://nuxt.com/docs/api/kit/logging
commit: |
…gacy logger implementations
…n favor of unified logging API
all done and updated |
…rian/vite-devtools into feat/unified-logger-api
| } | ||
| else { | ||
| left -= entries.length | ||
| left -= items.length |
There was a problem hiding this comment.
I appreciated the bugfix (that I also found and fixed) - but please avoid changes like this to focus on the scope of PR.
| }, | ||
| "@vitejs/devtools#build": { | ||
| "dependsOn": [ | ||
| "@vitejs/devtools-vite#dev:prepare" |
There was a problem hiding this comment.
I would also appreciated for this change to be in another PR.
Description
This PR proposes a unified logging API for Vite DevTools to replace scattered
console.*calls with a consistent, configurable logging system. This is an RFC/proposal for discussion - feedback welcome!Related TODOs in codebase:
// TODO: A unified logger APIinpackages/core/src/client/webcomponents/state/setup-script.ts// TODO: implement logsinpackages/core/src/node/host-docks.tsMotivation
Currently, logging in Vite DevTools is inconsistent:
[VITE DEVTOOLS],[Vite DevTools],[vite-devtools],⬢Proposed API
What's Included
docs/rfcs/0001-unified-logging-api.mddocs/rfcs/0001-unified-logging-api-examples.mdpackages/kit/src/utils/logger-types.tspackages/kit/src/utils/logger-node.tspackages/kit/src/utils/logger-client.tspackages/kit/src/utils/log-collector.tspackages/kit/src/utils/logger.test.tsKey Features
logger.child()debug | info | warn | error | silentwith filteringlogger.info('msg', { key: value })LogCollectorenables the planned "Logs" dock panellogger.setLevel('debug')and env var supportExample Migration
Before:
After:
Open Questions
Next Steps (if approved)
console.*calls across packagesisHidden: false)Looking for feedback on the overall approach before proceeding with the full migration!
Linked Issues
#9
Additional context