Skip to content

fix: namespace log timestamp configuration - #403

Open
codeforester wants to merge 2 commits into
mainfrom
bug/394-20260930-bug-log-utc-is-an-unnamespaced-environment-variable
Open

codeforester wants to merge 2 commits into
mainfrom
bug/394-20260930-bug-log-utc-is-an-unnamespaced-environment-variable

Conversation

@codeforester

Copy link
Copy Markdown
Contributor

Fixes #394

Summary

  • add namespaced BASE_CLI_LOG_UTC configuration with precedence
  • retain LOG_UTC during the 0.5 window with a deprecation warning
  • document the removal timeline and add coverage

Validation

  • UV_CACHE_DIR=/private/tmp/base-cli-uv-cache uv run --extra dev pytest -q tests/test_logging.py
  • Ruff and strict mypy with the Typer extra pass locally

Hosted checks are expected to run on this branch.

Comment thread lib/python/base_cli/logging.py Outdated
resolved_use_utc = configured_use_utc == "1"
else:
if legacy_use_utc is not None:
warnings.warn(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Correctness risk: warnings.warn() for the legacy LOG_UTC env var has no exception handling anywhere in the call chain. If a consumer follows this project's own docs/migrations.md guidance and sets warnings.simplefilter("error", BaseCliDeprecationWarning) globally (e.g. in test setup), and their environment still has LOG_UTC=1 set with BASE_CLI_LOG_UTC unset, the raised warning propagates uncaught — _app_core.py only wraps the configure_logger(...) call in except OSError — crashing every CLI invocation at logger setup instead of just emitting a warning.

else:
configured_use_utc = os.environ.get("BASE_CLI_LOG_UTC")
legacy_use_utc = os.environ.get("LOG_UTC")
if configured_use_utc is not None:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Correctness (silent behavior): when both BASE_CLI_LOG_UTC and LOG_UTC are set, the legacy variable is silently ignored with no deprecation warning at all, since the legacy_use_utc check is only reached in the else branch. A user mid-migration with both set gets correct behavior (new var wins) but no signal that LOG_UTC is deprecated and currently doing nothing — they may keep the stale variable indefinitely.

Comment thread lib/python/base_cli/logging.py Outdated
if configured_use_utc is not None:
resolved_use_utc = configured_use_utc == "1"
else:
if legacy_use_utc is not None:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Minor: the deprecation warning fires whenever LOG_UTC is present in the environment at all, even for an inert empty-string value with no behavioral effect ("" == "1" is False, same as unset). A CI template that exports LOG_UTC= as a leftover placeholder rather than unsetting it would now emit a spurious BaseCliDeprecationWarning on every run, polluting warning-capturing test output for a variable that was never doing anything.

Comment thread docs/integrations.md

Set `BASE_CLI_LOG_UTC=1` to make the default text formatter use UTC
timestamps. The namespaced variable takes precedence over the legacy setting.
`LOG_UTC` remains recognized during the 0.5 compatibility window, but emits a

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Policy violation: docs/api-stability.md requires every deprecation to "remain supported for at least two minor releases and 90 calendar days, whichever is longer." Current VERSION is 0.4.3, so introducing the warning in 0.5 and scheduling removal in 0.6 is only one minor release apart — a user upgrading from 0.5.x straight to 0.6.0 loses LOG_UTC support without the two-minor-release window this project's own policy promises.

@codeforester

Copy link
Copy Markdown
Contributor Author

Two additional findings (files not touched by this diff, so not postable as inline comments):

  1. README.md still tells users to set the now-deprecated LOG_UTC=1 and never mentions the new BASE_CLI_LOG_UTC — directly contradicting the migration this PR introduces. A new user following README's onboarding instructions would adopt the variable this same PR just deprecated, triggering a BaseCliDeprecationWarning on day one with no pointer to the replacement.

  2. No CHANGELOG.md entry was added for this deprecation. docs/api-stability.md requires every deprecation to "appear in CHANGELOG.md under the release that introduces the warning," and states "a deprecation is not complete until the warning, docs, tests, and changelog agree." This PR touches docs/integrations.md, lib/python/base_cli/logging.py, and tests/test_logging.py, but not CHANGELOG.md.

This branch has not been deployed

No deployments
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.

bug: LOG_UTC is an unnamespaced environment variable

1 participant