Skip to content

fix(mlog): use local timezone for log timestamps#919

Open
rz467fzs7d wants to merge 1 commit intoIrineSistiana:mainfrom
rz467fzs7d:fix/local-timezone-log
Open

fix(mlog): use local timezone for log timestamps#919
rz467fzs7d wants to merge 1 commit intoIrineSistiana:mainfrom
rz467fzs7d:fix/local-timezone-log

Conversation

@rz467fzs7d
Copy link
Copy Markdown

@rz467fzs7d rz467fzs7d commented Feb 27, 2026

Summary

  • Fix log timestamps showing UTC instead of local timezone
  • Use zapcore.TimeEncoderOfLayout(time.RFC3339) which respects TZ environment variable via time.Format

Problem

MosDNS logs currently show UTC timestamps even when system timezone is set to a different value (e.g., CST for China). This is because Zap's default encoder uses UTC.

Solution

Use zapcore.TimeEncoderOfLayout(time.RFC3339) which internally calls time.Format. Since time.Format automatically uses local timezone (by reading TZ env var), the log timestamps will match system timezone.

Test plan

  • Build passes
  • Deploy and verify log timestamps match system timezone

🤖 Generated with Claude Code

Use time.Local() in encoder to respect TZ environment variable.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

1 participant