-
Notifications
You must be signed in to change notification settings - Fork 1
feat(logging): introduce logging configuration and infrastructure #672
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
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Pull request overview
This PR introduces a comprehensive logging infrastructure for the Sanity SDK, providing namespace-based, multi-level logging capabilities. The implementation follows a clean separation between public API and internal utilities, with the logging system designed to be opt-in and tree-shakeable for production builds.
Key Changes
- Logging core implementation with namespace filtering, log levels, instance context injection, and sensitive data sanitization
- Public API wrapper (
configureLogging) that provides a clean interface for SDK users to control logging behavior - Comprehensive test suite with 28 tests covering configuration, filtering, formatting, and context handling
- Developer documentation with usage examples for both SDK users and maintainers
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
packages/core/src/utils/logger.ts |
Core logging implementation with logger creation, formatting, sanitization, and utility functions for timers and RxJS logging |
packages/core/src/utils/logger.test.ts |
Comprehensive test suite covering all major logging functionality including configuration, levels, namespaces, sanitization, and instance context |
packages/core/src/config/loggingConfig.ts |
Public API wrapper that exports configureLogging function with extensive JSDoc examples for users and maintainers |
packages/core/src/utils/logger-usage-example.md |
Usage documentation showing real-world examples for SDK users, maintainers, and multi-instance scenarios |
packages/core/src/_exports/index.ts |
Adds export of public logging API (configureLogging, LoggerConfig, LogLevel types) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 11 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Description
Adds a complete logging infrastructure for the Sanity SDK
This PR introduces a flexible, namespace-based logging system that will help both SDK users and maintainers debug issues across the codebase. The infrastructure supports:
[project:x] [dataset:y]when available, making multi-instance debugging much easierconfigureLogging()- simple, single source of truthWhy? Currently, there's no systematic way to debug what's happening inside the SDK. This makes it difficult to troubleshoot auth issues, document sync problems, query behavior, etc. This infrastructure provides the foundation for adding meaningful debug logs throughout the codebase.
Note: This PR contains only the infrastructure - no actual logging is added to stores or operations yet. Future PRs will incrementally add logging to auth, document, query, and other modules.
What to review
Key files to review:
packages/core/src/utils/logger.ts(~400 lines)packages/core/src/utils/logger.test.ts(~480 lines)packages/core/src/config/loggingConfig.ts(~110 lines)packages/core/src/utils/logger-usage-example.md(~140 lines)packages/core/src/_exports/index.ts(+1 line)What's affected:
configureLogging()Example usage:
✅ Comprehensive automated testing:
Manual testing:
Future PRs (not included here) will add logging to individual modules (auth, document, query, etc.) and will include tests for those specific integrations.
Fun gif