Skip to content

fix: use stdlib logging instead of print (stderr)#73

Closed
Jah-yee wants to merge 1 commit into
xing5:mainfrom
Jah-yee:fix/use-logger
Closed

fix: use stdlib logging instead of print (stderr)#73
Jah-yee wants to merge 1 commit into
xing5:mainfrom
Jah-yee:fix/use-logger

Conversation

@Jah-yee
Copy link
Copy Markdown

@Jah-yee Jah-yee commented May 1, 2026

Maintainer feedback in #72: 'use a proper logger instead of changing print everywhere'.

This PR replaces all print() calls with Python stdlib logging, configured to write to stderr via basicConfig. This:

  • Satisfies the maintainer's request for a 'proper logger'
  • Preserves MCP stdio JSON-RPC framing (only log messages go to stderr, tool data stays on stdout)
  • Uses INFO level for process steps, ERROR level for failures

Changes:

  • Add import logging and logger = logging.getLogger(__name__)
  • Configure logging.basicConfig(level=INFO, stream=sys.stderr, format='%(message)s')
  • Replace all print() calls with logger.info() / logger.error()
  • Remove the file=sys.stderr from all calls (handled by basicConfig)

Closes #72.

Maintainer feedback: use a proper logger instead of changing print to
file=sys.stderr. Switch all print() calls to logging.info/error.

Logger configured with basicConfig(level=INFO, stream=sys.stderr)
which preserves MCP stdio JSON-RPC framing - only log messages go
to stderr, tools return data on stdout.

Fixes: xing5#72
@Jah-yee
Copy link
Copy Markdown
Author

Jah-yee commented May 1, 2026

Supersedes Jah-yee/mcp-google-sheets#72. Changes: replaced print→stderr approach with stdlib logging (per maintainer request), still writes to stderr to preserve MCP stdio framing.

@xing5
Copy link
Copy Markdown
Owner

xing5 commented May 14, 2026

Closing as superseded by #80. #80 keeps the stdio logging fix focused, configures logging only from main(), adds stdout-safety regression tests, and avoids broader observability changes in the same patch.

@xing5 xing5 closed this May 14, 2026
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