Skip to content

Add logger framework for the sdk#171

Merged
iam404 merged 1 commit into
next-1.0.0from
add-logger
May 24, 2026
Merged

Add logger framework for the sdk#171
iam404 merged 1 commit into
next-1.0.0from
add-logger

Conversation

@iam404

@iam404 iam404 commented May 24, 2026

Copy link
Copy Markdown
Member

@iam404 iam404 requested a review from a team as a code owner May 24, 2026 19:36
@iam404 iam404 requested a review from Copilot May 24, 2026 19:37

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2eeec94d4d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds a stdlib logging-based logging framework to the pyTFE SDK, including transport-level HTTP tracing with redaction/truncation controls and accompanying documentation/tests.

Changes:

  • Introduces pytfe._logging with setup_logging(), header/body redaction, and RoundTrip request/response formatting.
  • Integrates transport logging into HTTPTransport (DEBUG round-trips, INFO retry decisions, DEBUG transport exceptions).
  • Adds documentation (README.md, docs/LOGGING.md, AGENTS.md) and unit tests covering namespace, env config, redaction, truncation, and transport behavior.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/units/test_logging.py Adds unit tests for logger naming, env-driven config, redaction/truncation, and transport logging behavior.
src/pytfe/_logging.py Implements logging primitives: env-based setup, redaction helpers, and RoundTrip formatter.
src/pytfe/_http.py Emits transport logs (retry/exception) and adds DEBUG round-trip logging via RoundTrip.
src/pytfe/init.py Exports setup_logging from the package root.
README.md Documents how to enable/configure logging and links to LOGGING.md.
docs/LOGGING.md Adds detailed internal/reference documentation for the logging framework.
AGENTS.md Updates contributor guidance to use the new logging framework instead of print()/ad-hoc loggers.
Comments suppressed due to low confidence (1)

src/pytfe/_http.py:125

  • This INFO retry log prints the full url string. For requests to presigned blob URLs (state version downloads/uploads, redirect Location targets), the URL query often contains signatures/credentials; logging it at INFO can leak secrets in normal production logs. Consider logging a sanitized URL (path only, or redacted query) here, consistent with the redaction guarantees described in LOGGING.md.
                transport_logger.info(
                    "retrying %s %s after %s (status=%d, attempt=%d)",
                    method,
                    url,
                    f"{retry_after:.2f}s" if retry_after else "backoff",
                    resp.status_code,
                    attempt,
                )

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/pytfe/_logging.py
Comment on lines +205 to +213
# httpx.URL has .path / .query (bytes) — render in a way matching
# what the wire saw, but with query unquoted for human reading.
from urllib.parse import unquote, urlparse

url = urlparse(str(request.url))
query = f"?{unquote(url.query)}" if url.query else ""
path = unquote(url.path) or "/"

sb: list[str] = [f"> {request.method} {path}{query}"]
Comment thread src/pytfe/_http.py
Comment on lines +104 to +110
transport_logger.debug(
"transport exception on %s %s (attempt %d): %s",
method,
url,
attempt,
e,
)
Comment thread docs/LOGGING.md
| `PYTFE_LOG_HEADERS` | `false` | When truthy, include request/response headers in `RoundTrip` output. Sensitive ones are still redacted; this just turns on the `> * Header: value` lines at all. |
| `PYTFE_LOG_TRUNCATE_BYTES` | `1024` | Truncation budget for any single string in a logged body. Values below 96 are clamped up. |

All three are read at call time, not at import — switching `PYTFE_LOG_HEADERS=true` in the middle of a long-running process takes effect on the next request.
@iam404 iam404 merged commit 5637c74 into next-1.0.0 May 24, 2026
15 checks passed
@hashicorp hashicorp deleted a comment from chatgpt-codex-connector Bot May 24, 2026
@hashicorp hashicorp deleted a comment from chatgpt-codex-connector Bot May 24, 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