detached fd9e3fe

fix(logs): track and report journalctl check errors

Address review feedback: capture errors from hasJournalctlLogs calls
and include diagnostic information when both user and system service
checks fail, improving troubleshooting.
commit
fd9e3fea5e4bf3f3028a870e938f94bd2e6f3800
author
brice · · 2026-01-16 05:11 UTC
parent
6dbe27e
signature
unsigned
1 file · +15 -2
M internal/app/logs.go +15 -2
@@ -195,16 +195,29 @@ func hasJournalctl() bool {
195195 // showJournalctlLog displays logs from journalctl.
196196 // It first tries user service, then falls back to system service.
197197 func showJournalctlLog(follow bool, lines int) error {
198+ var userErr, systemErr error
199+
198200 // Try user service first (works without special permissions)
199- if hasLogs, _ := hasJournalctlLogs(true); hasLogs {
201+ hasLogs, err := hasJournalctlLogs(true)
202+ if err != nil {
203+ userErr = err
204+ } else if hasLogs {
200205 return runJournalctl(follow, lines, true)
201206 }
202207
203208 // Fall back to system service
204- if hasLogs, _ := hasJournalctlLogs(false); hasLogs {
209+ hasLogs, err = hasJournalctlLogs(false)
210+ if err != nil {
211+ systemErr = err
212+ } else if hasLogs {
205213 return runJournalctl(follow, lines, false)
206214 }
207215
216+ // If either check failed with an error, include that information
217+ if userErr != nil || systemErr != nil {
218+ return fmt.Errorf("gordon service not found in journalctl (user: %v, system: %v)", userErr, systemErr)
219+ }
220+
208221 return fmt.Errorf("gordon service not found in journalctl: enable file logging in config.toml or run gordon as a systemd service")
209222 }
210223
@@ -195,16 +195,29 @@ func hasJournalctl() bool {
195 // showJournalctlLog displays logs from journalctl.195 // showJournalctlLog displays logs from journalctl.
196 // It first tries user service, then falls back to system service.196 // It first tries user service, then falls back to system service.
197 func showJournalctlLog(follow bool, lines int) error {197 func showJournalctlLog(follow bool, lines int) error {
198+ var userErr, systemErr error
199+
198 // Try user service first (works without special permissions)200 // Try user service first (works without special permissions)
199- if hasLogs, _ := hasJournalctlLogs(true); hasLogs {201+ hasLogs, err := hasJournalctlLogs(true)
202+ if err != nil {
203+ userErr = err
204+ } else if hasLogs {
200 return runJournalctl(follow, lines, true)205 return runJournalctl(follow, lines, true)
201 }206 }
202 207
203 // Fall back to system service208 // Fall back to system service
204- if hasLogs, _ := hasJournalctlLogs(false); hasLogs {209+ hasLogs, err = hasJournalctlLogs(false)
210+ if err != nil {
211+ systemErr = err
212+ } else if hasLogs {
205 return runJournalctl(follow, lines, false)213 return runJournalctl(follow, lines, false)
206 }214 }
207 215
216+ // If either check failed with an error, include that information
217+ if userErr != nil || systemErr != nil {
218+ return fmt.Errorf("gordon service not found in journalctl (user: %v, system: %v)", userErr, systemErr)
219+ }
220+
208 return fmt.Errorf("gordon service not found in journalctl: enable file logging in config.toml or run gordon as a systemd service")221 return fmt.Errorf("gordon service not found in journalctl: enable file logging in config.toml or run gordon as a systemd service")
209 }222 }
210 223

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 7

Tags 106

↑↓ moveenter openesc close