Skip to content

fix(logging): Apply LOG_JSON pattern to all logger calls#211

Merged
polaz merged 8 commits intomainfrom
feat/#209-fixlogging-apply-logjson-pattern-to-all-logger-cal
Jan 25, 2026
Merged

fix(logging): Apply LOG_JSON pattern to all logger calls#211
polaz merged 8 commits intomainfrom
feat/#209-fixlogging-apply-logjson-pattern-to-all-logger-cal

Conversation

@polaz
Copy link
Copy Markdown
Member

@polaz polaz commented Jan 25, 2026

Summary

  • 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 all test mocks to include helper functions and match new argument order

Changes

  • 74 files modified (42 source files, 32 test files)
  • 1267 insertions, 1220 deletions

Test plan

  • All 4116 tests pass
  • Lint passes with 0 errors
  • Build succeeds

Closes #209

- 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
Copilot AI review requested due to automatic review settings January 25, 2026 13:39
@github-actions
Copy link
Copy Markdown

github-actions bot commented Jan 25, 2026

Test Coverage Report

Overall Coverage: 94.44%

Metric Percentage
Statements 93.89%
Branches 85.51%
Functions 84.55%
Lines 94.44%

View detailed coverage report

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 25, 2026

Copy link
Copy Markdown

Copilot AI left a 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 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) in src/logger.ts that automatically format logs based on LOG_JSON environment variable
  • Converted 144 logger calls from logger.level({data}, "message") to logLevel("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 prettyPrint option 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)

polaz added 2 commits January 25, 2026 15:44
- 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
Copy link
Copy Markdown

Copilot AI left a 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 75 out of 75 changed files in this pull request and generated no new comments.

polaz added 2 commits January 25, 2026 15:57
…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
Copy link
Copy Markdown

Copilot AI left a 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 76 out of 76 changed files in this pull request and generated no new comments.

polaz added 3 commits January 25, 2026 16:05
- 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
Copy link
Copy Markdown

Copilot AI left a 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 78 out of 78 changed files in this pull request and generated no new comments.

@polaz polaz merged commit 168783a into main Jan 25, 2026
26 of 27 checks passed
@polaz polaz deleted the feat/#209-fixlogging-apply-logjson-pattern-to-all-logger-cal branch January 25, 2026 14:21
sw-release-bot bot pushed a commit that referenced this pull request Jan 25, 2026
## [6.46.1](v6.46.0...v6.46.1) (2026-01-25)

### Bug Fixes

* **logging:** Apply LOG_JSON pattern to all logger calls ([#211](#211)) ([168783a](168783a)), closes [#209](#209) [#209](#209) [#209](#209) [#209](#209) [#209](#209)
@sw-release-bot
Copy link
Copy Markdown

🎉 This PR is included in version 6.46.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(logging): Apply LOG_JSON pattern to all logger calls (multiline output remains in 144 places)

2 participants