feat(logging): add size-limited log rotation via lumberjack#1401
Draft
adamshiervani wants to merge 1 commit into
Draft
feat(logging): add size-limited log rotation via lumberjack#1401adamshiervani wants to merge 1 commit into
adamshiervani wants to merge 1 commit into
Conversation
Add lumberjack-based log rotation to prevent unbounded growth of the application log file on long-running devices. The app now writes to /userdata/jetkvm/app.log (managed, 50MB max, 1 backup) instead of relying solely on the shell redirect to last.log. This works safely regardless of whether the rv1106-system shell redirect is updated: lumberjack writes to a different file path, so the old redirect to last.log is harmless. Also log app and system version at startup using NoLevel so it always appears regardless of configured log level.
terryrankine
added a commit
to terryrankine/kvm
that referenced
this pull request
May 7, 2026
Add rotating file output to zerolog via gopkg.in/natefinch/lumberjack.v2. Writes to /userdata/picokvm/app.log (fork path; upstream uses jetkvm/). 50 MB max size, 1 backup retained, no compression. The directory guard (os.Stat) silently skips the file writer when the data directory does not exist, so the binary continues to work on dev hosts where the path is absent. Also change the startup version-banner to logger.Log() (no level) so it is always written regardless of the configured log level. - internal/logging/logger.go: AppLogPath constant, newDefaultLogOutput(), replace MultiLevelWriter init with function call - main.go: logger.Info() → logger.Log() for startup banner - go.mod/go.sum: add gopkg.in/natefinch/lumberjack.v2 v2.2.1 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
last.loggrowth on long-running devices/userdata/jetkvm/app.log(50 MB max, 1 backup) via a new zerolog multi-writer, independent of the shell redirect inRkLunch.shNoLevelso it always appears regardless of configured log levelBackground
/userdata/jetkvm/last.loggrows unbounded for the lifetime of a process run — the only reset is a process restart (shell>truncation). On a device that stays up for months, this can consume significant space on the 13 GB/userdatapartition.The rv1106-system image and the app have independent update paths, so we can't guarantee the shell redirect will be removed when the app is updated. This solution writes to a different file (
app.log), making it safe regardless of whether the old redirect is still in place.Changes
go.mod/go.sumgopkg.in/natefinch/lumberjack.v2internal/logging/logger.gointernal/supervisor/consts.goAppLogPath→/userdata/jetkvm/app.logmain.goInfo()toLog()(NoLevel)ui/e2e/global-teardown.tsapp.loginstead oflast.logui/e2e/helpers.tsrestartAppViaSSHredirects to/dev/nullui/e2e/log-rotation.spec.tsDEVELOPMENT.mdTest plan
/userdata/jetkvm/app.logis created and contains log outputapp.logcontainsapp_versionandsystem_versionfieldsGET /diagnostics) includesapp.logtail -f /userdata/jetkvm/app.logworks for live log viewinglast.logandapp.logare written —app.logis authoritativenpx playwright test log-rotation