-
-
Notifications
You must be signed in to change notification settings - Fork 67
feat(kit): RFC - Unified Logging API proposal #155
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
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
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