Skip to content

[MM-63462] Use local time for backup log filenames - #60

Open
hanzei wants to merge 4 commits into
masterfrom
MM-63462-local-time-backup-filenames
Open

[MM-63462] Use local time for backup log filenames#60
hanzei wants to merge 4 commits into
masterfrom
MM-63462-local-time-backup-filenames

Conversation

@hanzei

@hanzei hanzei commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Backup log filenames were formatted in UTC (lumberjack default) while log entry timestamps used the server's local timezone. This caused a confusing mismatch for admins trying to correlate a rotation event with something that happened at a specific local time — the filename would show e.g. T09-14-56 (UTC) while the last entry inside the file said 14:44:55 +05:30.

Setting LocalTime: true on the lumberjack logger aligns backup filenames with log entry timestamps. Admins who prefer UTC can achieve consistent UTC output by running the server process in the UTC timezone (TZ=UTC).

Testing

A test for this was explored and then removed. The only meaningful approach was to mutate the global time.Local to a non-UTC timezone, trigger rotation, and verify the backup filename reflected local time. However, lumberjack's internal millRun goroutine reads time.Local via time.Parse even after the logger is shut down (lumberjack's Close() does not drain that goroutine), so restoring time.Local in a defer races with it. There is no way to wait for the mill goroutine from outside the library.

The fix is a one-liner against a well-understood lumberjack flag; the behavior is covered by lumberjack's own test suite (TestLocalTime).

Ticket

https://mattermost.atlassian.net/browse/MM-63462

🤖 Generated with Claude Code

Backup filenames previously used UTC regardless of the server's local
timezone, while log entries used local time. This produced a confusing
mismatch for admins correlating rotations with events in their local
clock.

Setting LocalTime: true aligns filenames with log entry timestamps.
Admins who want UTC behaviour can achieve it by running the server
process in the UTC timezone.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown

Test Results

353 tests  ±0   353 ✅ ±0   1m 31s ⏱️ -2s
 10 suites ±0     0 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit 33e2ccb. ± Comparison against base commit 34e81f8.

♻️ This comment has been updated with latest results.

hanzei and others added 3 commits September 9, 2026 09:56
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Mutating time.Local races with lumberjack's internal mill goroutine,
which reads time.Local via time.Parse even after the logger is shut down.
There's no way to drain that goroutine from outside lumberjack.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@hanzei
hanzei requested a review from davidkrauser September 9, 2026 08:04
@hanzei hanzei added the 2: Dev Review Requires review by a core committer label Sep 9, 2026
@hanzei
hanzei marked this pull request as ready for review September 9, 2026 08:04
@coderabbitai

coderabbitai Bot commented Sep 9, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Essentials

Run ID: e6cdba12-b2bb-439b-8db0-de8869aa311f

📥 Commits

Reviewing files that changed from the base of the PR and between 34e81f8 and 33e2ccb.

📒 Files selected for processing (1)
  • targets/file.go

Included review availability: 4 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour.


📝 Walkthrough

Walkthrough

NewFileTarget now configures lumberjack to use local time in rotated log filenames.

Changes

File target logging

Layer / File(s) Summary
Configure local-time rotation
targets/file.go
NewFileTarget sets lumberjack's LocalTime option to true.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~2 minutes

Merge Risk: ⚪ Minimal · up to 33e2c

Rotated file-log names now use the server’s local timezone, matching log-entry timestamps. No merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: configuring backup log filenames to use local time.
Description check ✅ Passed The description explains the local-time filename change, its purpose, testing considerations, and related ticket. It is directly related to the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch MM-63462-local-time-backup-filenames

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2: Dev Review Requires review by a core committer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant