Conversation
- Create helper functions (logInfo, logWarn, logError, logDebug) in logger.ts
- Convert all logger calls from logger.level({data}, "message") to logLevel("message", {data}) format
- Update test mocks to include helper functions and match new argument order
- Fix 74 files across src/ and tests/ to use consistent logging pattern
Closes #209
Test Coverage ReportOverall Coverage: 94.44%
|
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Pull request overview
This PR fixes multiline logging output by implementing helper functions that handle both JSON and plain text logging modes consistently across the codebase.
Changes:
- Created four helper functions (
logInfo,logWarn,logError,logDebug) insrc/logger.tsthat automatically format logs based onLOG_JSONenvironment variable - Converted 144 logger calls from
logger.level({data}, "message")tologLevel("message", {data})format across 42 source files - Updated test mocks in 32 test files to include the new helper functions and match the new argument order
- Removed obsolete
prettyPrintoption from file storage configuration
Reviewed changes
Copilot reviewed 74 out of 74 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/logger.ts | Added four helper functions (logInfo, logWarn, logError, logDebug) with formatDataPairs utility |
| src/main.ts | Updated all logger calls to use new helpers with correct argument order |
| src/server.ts | Converted 30+ logger calls to new helper pattern |
| src/session-manager.ts | Updated session lifecycle logging to use helpers |
| src/services/ConnectionManager.ts | Converted connection and schema introspection logging |
| src/services/TokenScopeDetector.ts | Updated token scope detection and logging |
| src/services/SchemaIntrospector.ts | Converted GraphQL schema introspection logging |
| src/services/ToolAvailability.ts | Updated tool availability logging |
| src/services/WidgetAvailability.ts | Converted widget validation logging |
| src/services/GitLabVersionDetector.ts | Updated version detection logging |
| src/utils/fetch.ts | Converted all fetch-related logging (requests, retries, errors) |
| src/utils/schema-utils.ts | Updated schema mode detection and filtering logging |
| src/registry-manager.ts | Converted registry filtering and tool override logging |
| src/profiles/*.ts | Updated all profile/preset loading and application logging (4 files) |
| src/oauth/**/*.ts | Converted OAuth flow, session, and storage logging (10 files) |
| src/middleware/*.ts | Updated middleware logging for auth and rate limiting (2 files) |
| src/entities/**/*.ts | Converted entity-specific logging (3 files) |
| src/discovery/*.ts | Updated auto-discovery logging (3 files) |
| src/cli-utils.ts | Converted CLI argument parsing logging |
| src/handlers.ts | Updated MCP request handler logging |
| src/graphql/DynamicWorkItemsQuery.ts | Converted query building logging |
| src/logging/request-tracker.ts | Updated request tracking debug logging |
| src/logging/connection-tracker.ts | Converted to use logInfo and logDebug helpers |
| src/oauth/storage/types.ts | Removed prettyPrint option from StorageConfig |
| tests/unit/**/*.test.ts | Updated 20 test files to mock helper functions |
| tests/integration/**/*.test.ts | Updated integration test mocks (1 file) |
- Add tests for logInfo, logWarn, logError, logDebug functions - Test JSON mode and plain mode output formats - Test nested objects and various data types handling Related to #209
- Add special case for Error objects to preserve stack/message - Handle null and undefined values explicitly - Add tests for Error and undefined handling Related to #209
…arning - Add test for 429 response when IP rate limit exceeded - Add test for debug log when approaching 80% threshold - Use unique IPs per test to ensure per-IP isolation Related to #209
- Add test for error when called before initialization - Add test for early return when already introspected Related to #209
- Add test verifying separate rate limits tracked per IP address - Add test for 429 response when IP rate limit exceeded - Add test for debug log when approaching 80% threshold
…pping - Add Authorization Code Flow tests (store, get, delete, count) - Add MCP session mapping tests (associate, get by MCP session, remove) - Add tests for getBackendType, getStats, clear, stopCleanupInterval - Add tests for getSessionCount, getDeviceFlowCount, getAuthCodeCount - Add updateSession edge case tests (non-existent, refresh token update)
- Add tests for registerHandler (public/confidential clients, validation) - Add tests for getRegisteredClient and isValidRedirectUri - Add test for error handling in registration
|
🎉 This PR is included in version 6.46.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
logInfo,logWarn,logError,logDebug) inlogger.tslogger.level({data}, "message")tologLevel("message", {data})formatChanges
Test plan
Closes #209