Skip to content

Commit a24d308

Browse files
pnachtsigmavirus24
andauthored
Set trusted publishing logging to INFO/WARN (#1247)
* Set trusted publishing logging to INFO/WARN Trusted publishing is the only part of the codebase using `logger.debug()`, which can't be easily accessed from the CLI. This PR changes these to either `logger.info` or `logger.warning()`, such that all are visible with `--verbose`. Signed-off-by: Pedro Kaj Kjellerup Nacht <[email protected]> * Set all but one to WARN, add changelog Signed-off-by: Pedro Kaj Kjellerup Nacht <[email protected]> --------- Signed-off-by: Pedro Kaj Kjellerup Nacht <[email protected]> Co-authored-by: Ian Stapleton Cordasco <[email protected]>
1 parent becf1a8 commit a24d308

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

1247.misc.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Log when performing built-in trusted publishing key exchange.

twine/auth.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ def _make_trusted_publishing_token(self) -> t.Optional[TrustedPublishingToken]:
181181
)
182182

183183
if oidc_token is None:
184-
logger.debug("This environment is not supported for trusted publishing")
184+
logger.warning("This environment is not supported for trusted publishing")
185185
if self._tp_token and int(time.time()) > cast(
186186
int, self._tp_token.get("expires", self._expires)
187187
):
@@ -190,7 +190,7 @@ def _make_trusted_publishing_token(self) -> t.Optional[TrustedPublishingToken]:
190190
# while longer, let's continue using it instead of prompting
191191
return self._tp_token
192192

193-
logger.debug("Got OIDC token for audience %s", audience)
193+
logger.warning("Got OIDC token for audience %s", audience)
194194

195195
token_exchange_url = f"https://{repository_domain}/_/oidc/mint-token"
196196

@@ -216,7 +216,7 @@ def _make_trusted_publishing_token(self) -> t.Optional[TrustedPublishingToken]:
216216
f" reasons:\n\n{reasons}"
217217
)
218218

219-
logger.debug("Minted upload token for trusted publishing")
219+
logger.warning("Minted upload token for trusted publishing")
220220
self._tp_token = cast(TrustedPublishingToken, mint_token_payload)
221221
self._expires = int(time.time()) + 900
222222
return self._tp_token
@@ -278,7 +278,7 @@ def password_from_keyring_or_trusted_publishing_or_prompt(self) -> str:
278278
return password
279279

280280
if self.is_pypi() and self.username == TOKEN_USERNAME:
281-
logger.debug(
281+
logger.info(
282282
"Trying to use trusted publishing (no token was explicitly provided)"
283283
)
284284
if (token := self.make_trusted_publishing_token()) is not None:

0 commit comments

Comments
 (0)