Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 7, 2025

Update AGENTS.md with Logging Documentation

This PR adds a comprehensive logging section to AGENTS.md that documents how to instrument TypeScript code with logging and tracing.

Changes Made

  • Explore repository structure and understand existing logging implementation
  • Review logging.ts to understand debug package usage
  • Review existing TypeScript files to see current logging patterns
  • Add new "Logging and Tracing" section to AGENTS.md
  • Document debug package usage with examples
  • Include guidelines on logger categories per file
  • Add examples of printf-like syntax
  • Include security warnings about not logging secrets
  • Run tests and linting to ensure no issues
  • Address code review feedback for safer examples
  • Address PR comment to use helper function from logging.ts
  • Configure .gitattributes for dist/* merge strategy
  • Merge main branch with all latest updates
  • Final validation with all checks passing

Files Changed

  • AGENTS.md - Added comprehensive logging and tracing documentation
  • src/logging.ts - Added createLogger() helper function for creating per-file loggers
  • .gitattributes - Added merge=ours strategy for dist/* files to handle generated artifacts
  • dist/index.js.map - Build artifact from logging.ts changes

Documentation Highlights

The new section covers:

  1. Debug Package Overview - Introduction to the debug package and its benefits
  2. Setting Up Logging - Reference to logging.ts file
  3. Using Debug Loggers - How to create dedicated logger instances per file using createLogger('filename') helper
  4. Printf-Style Formatting - Detailed examples of format specifiers (%s, %d, %j, %o, %%)
  5. Logger Naming Conventions - Consistent naming pattern across files
  6. Security Considerations - Critical warnings about not logging secrets with safe/unsafe examples
  7. Adding Logging to New Code - Step-by-step checklist for developers
  8. Enabling Debug Output - How to use DEBUG environment variable

Latest Updates

  • Added createLogger() helper function to src/logging.ts for creating per-file loggers
  • Updated all documentation examples to use createLogger('name') instead of directly importing debug
  • Maintains the namespace pattern mcp:<name> internally while providing a cleaner API
  • Configured .gitattributes to use merge=ours for dist/* files to prevent merge conflicts with generated artifacts
  • Merged main branch successfully, bringing in latest test suites and agentic workflows

All tests pass (49 tests across 5 test files) and the documentation follows the existing format and style.

Original prompt

Update AGENTS.md:

Add section on logging:

instrument the typescript code with logging/tracing using the "debug" package (see logging.ts).

Use a dedicated logger category for each file and add lots of logging calls using the optimized printf-like syntax.

Be careful about not logging secrets.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits November 7, 2025 12:51
- Document debug package usage with logging.ts
- Explain logger categories per file (mcp:filename pattern)
- Include printf-style formatting examples (%s, %d, %j, %o)
- Add security warnings about not logging secrets
- Provide safe logging patterns for sensitive data
- Include examples for adding logging to new code
- Document DEBUG environment variable usage

Co-authored-by: pelikhan <[email protected]>
- Use optional chaining for apiKey.substring() to handle undefined
- Replace type assertion with instanceof check for error handling
- Add fallback values for safer logging examples

Co-authored-by: pelikhan <[email protected]>
Copilot AI changed the title [WIP] Update AGENTS.md with logging section Document logging instrumentation patterns using debug package Nov 7, 2025
Copilot AI requested a review from pelikhan November 7, 2025 12:56
Copilot finished work on behalf of pelikhan November 7, 2025 12:56
AGENTS.md Outdated
import debug from 'debug'

// Create a dedicated logger for this file
const log = debug('mcp:server')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot use helper function from logger.ts instead of directly from the debug package

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated documentation to use createLogger() helper from logging.ts instead of directly importing debug package. Added the helper function in commit 55ec7c7.

- Add createLogger() helper function to logging.ts
- Update all documentation examples to use createLogger instead of directly importing debug
- Maintains namespace pattern 'mcp:<name>' internally
- Addresses feedback to use helper function from logging.ts

Co-authored-by: pelikhan <[email protected]>
Copilot AI changed the title Document logging instrumentation patterns using debug package Document logging instrumentation patterns using createLogger helper Nov 7, 2025
Copilot finished work on behalf of pelikhan November 7, 2025 13:05
Copilot AI requested a review from pelikhan November 7, 2025 13:05
@pelikhan pelikhan marked this pull request as ready for review November 7, 2025 13:07
@pelikhan
Copy link
Collaborator

pelikhan commented Nov 7, 2025

@copilot merge main

Merged commits:
- Add vitest test suites for TypeScript functions (#8)
- Add comprehensive input/output schema for stdio and http MCP transports (#7)
- Add agentic workflow for action metadata consistency checking (#11)
- Add agentic workflow for automated super-linter analysis and reporting (#4)

Resolved merge conflict in dist/index.js.map by rebuilding the package.

Co-authored-by: pelikhan <[email protected]>
Copy link
Contributor Author

Copilot AI commented Nov 7, 2025

@copilot merge main

Merged main branch in commit 9bf221d. All tests pass (49 tests across 5 test files). Resolved merge conflict in dist/index.js.map by rebuilding the package.

Copilot AI requested a review from pelikhan November 7, 2025 13:16
Copilot finished work on behalf of pelikhan November 7, 2025 13:16
@pelikhan
Copy link
Collaborator

pelikhan commented Nov 7, 2025

@copilot merge main and only keep AGENTS.md file changes

Removed files brought in from main branch merge:
- .github/workflows/check-consistency.md
- .github/workflows/super-linter-report.md
- CONTRIBUTING.md
- __tests__/docker.test.ts
- __tests__/logging.test.ts
- __tests__/port.test.ts
- __tests__/server.test.ts

Reverted modifications to files that were changed in merge:
- README.md
- __tests__/main.test.ts
- action.yml
- dist/index.js
- dist/index.js.map
- src/main.ts
- src/server.ts

Retained only the original PR changes:
- AGENTS.md (logging documentation)
- src/logging.ts (createLogger helper)

Co-authored-by: pelikhan <[email protected]>
Copy link
Contributor Author

Copilot AI commented Nov 7, 2025

@copilot merge main and only keep AGENTS.md file changes

Reverted merge in commit 32b29d9. PR now only contains AGENTS.md documentation and src/logging.ts changes. All other files from the main branch merge have been removed.

Copilot finished work on behalf of pelikhan November 7, 2025 13:28
Copy link
Collaborator

@pelikhan pelikhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot update .gitattributes and mark dist/* as generated merge ours

Then merge main

Copilot AI and others added 2 commits November 7, 2025 16:50
Added merge=ours to dist/** in .gitattributes to prefer our version during merges since dist files are generated artifacts.

Co-authored-by: pelikhan <[email protected]>
Merged commits from main:
- Move test files to src/ directory alongside source files (#12)
- Add daily test improver agentic workflow (#10)
- Add agentic workflow for automated super-linter analysis and reporting (#4)
- Add agentic workflow for action metadata consistency checking (#11)
- Add comprehensive input/output schema for stdio and http MCP transports (#7)
- Add vitest test suites for TypeScript functions (#8)

Used merge=ours strategy for dist/index.js.map to keep our generated version.
All 49 tests pass.

Co-authored-by: pelikhan <[email protected]>
Copy link
Contributor Author

Copilot AI commented Nov 7, 2025

@copilot update .gitattributes and mark dist/* as generated merge ours

Then merge main

Updated .gitattributes to mark dist/* with merge=ours strategy in commit 176ede8, then merged main branch in commit a18f2c4. The merge=ours strategy successfully kept our version of dist/index.js.map during the merge. All 49 tests pass.

Copilot AI requested a review from pelikhan November 7, 2025 16:59
Copilot finished work on behalf of pelikhan November 7, 2025 16:59
@pelikhan pelikhan closed this Nov 7, 2025
@pelikhan pelikhan deleted the copilot/update-agents-md-logging branch November 7, 2025 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants