Skip to content

fix: log timestamps respect configured timezone (#289)#290

Merged
kindralai[bot] merged 2 commits into
mainfrom
kindral/log-timezone-fix
Jul 10, 2026
Merged

fix: log timestamps respect configured timezone (#289)#290
kindralai[bot] merged 2 commits into
mainfrom
kindral/log-timezone-fix

Conversation

@kindralai

@kindralai kindralai Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Problem

Log timestamps in the admin Logs tab always show UTC time, regardless of the user-specified timezone in their config (You tab in admin UI). The root cause is _BufferHandler.emit() using datetime.fromtimestamp() without a tz argument, defaulting to the Docker container's system timezone (UTC).

Solution

  • Added module-level _LOG_TIMEZONE variable (default "UTC") and set_log_timezone() to update it after config loads
  • emit() now passes tz=ZoneInfo(_LOG_TIMEZONE) to datetime.fromtimestamp()
  • main.py calls set_log_timezone(config.agent.timezone) in _start_agent() after config is loaded

Acceptance criteria

  • Default behaviour unchanged: no timezone set → UTC timestamps
  • Configured timezone applied: US/Eastern shows correct EST offset
  • No new imports needed in admin.py (ZoneInfo already imported)
  • All existing log tests pass

Closes #289

_BufferHandler.emit() used datetime.fromtimestamp() without a tz
argument, which defaulted to the system (Docker) UTC regardless of
the user's configured timezone in agent config.

Changes:
- admin.py: add _LOG_TIMEZONE module variable (default 'UTC') and
  set_log_timezone() to update it after config loads
- admin.py: emit() now passes tz=ZoneInfo(_LOG_TIMEZONE) to
  datetime.fromtimestamp()
- main.py: call set_log_timezone(config.agent.timezone) after
  config is loaded in _start_agent()
- tests: two new tests verifying UTC default and US/Eastern offset

Closes #289.
@mattmezza

Copy link
Copy Markdown
Owner

@kindralai[bot] linting fails. Please install the pre-commit hook to auto lint before committing. This is getting annoying.

datetime.fromtimestamp() call exceeded 100-char limit, causing CI
lint failure on PR #290. Broke it across multiple lines.
@kindralai

kindralai Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

Fixed the lint issue — E501 line-too-long on the datetime.fromtimestamp() call. Broke it across multiple lines.

Also activated the pre-commit hook: git config core.hooksPath .githooks (or make setup-hooks / make setup from the humux/ dir). The .githooks/pre-commit script was already on main — it just wasn't wired up.

@mattmezza mattmezza left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

lgtm

@kindralai
kindralai Bot merged commit 29bdfd1 into main Jul 10, 2026
3 checks passed
@kindralai
kindralai Bot deleted the kindral/log-timezone-fix branch July 10, 2026 13:17
kindralai Bot added a commit that referenced this pull request Jul 10, 2026
…ia hooksPath

- Split datetime.fromtimestamp() call across multiple lines to stay
  under ruff's 100-char limit (fixes CI lint failure on PR #290)
- Set core.hooksPath = .githooks so the existing pre-commit hook
  (which runs ruff check) fires on every commit
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.

Log timestamps show UTC instead of the user's configured timezone

1 participant