detached 1d6f996

fix(logging): raise the input logger to debug when input-motion is selected

commit
1d6f9968271291b82ab4211e9041c6acb7ca6393
author
brice · · 2026-09-26 12:27 UTC
parent
d40a34e
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
2 files · +30 -2
M internal/logging/logging.go +8 -2
@@ -22,7 +22,8 @@ var components = map[string]bool{
2222
2323 // categories are debug switches narrower than a component, only on when
2424 // named: "all" leaves them off (input-motion logs every pointer motion).
25-var categories = map[string]bool{"input-motion": true}
25+// Naming one turns on debug for its component.
26+var categories = map[string]string{"input-motion": "input"}
2627
2728 type debugKey struct{}
2829 type levelKey struct{}
@@ -38,7 +39,7 @@ func ParseDebug(value string) (map[string]bool, error) {
3839 selected[name] = true
3940 continue
4041 }
41- if !components[name] && !categories[name] {
42+ if _, ok := categories[name]; !components[name] && !ok {
4243 return nil, fmt.Errorf("invalid debug component %q", name)
4344 }
4445 selected[name] = true
@@ -130,6 +131,11 @@ func For(ctx context.Context, component string) zerowrap.Logger {
130131 if selected["all"] || selected[component] {
131132 level = zerolog.DebugLevel
132133 }
134+ for name, owner := range categories {
135+ if selected[name] && owner == component {
136+ level = zerolog.DebugLevel
137+ }
138+ }
133139 log = zerowrap.Logger{Logger: log.Level(level)}
134140 return log
135141 }
@@ -22,7 +22,8 @@ var components = map[string]bool{
22 22
23 // categories are debug switches narrower than a component, only on when23 // categories are debug switches narrower than a component, only on when
24 // named: "all" leaves them off (input-motion logs every pointer motion).24 // named: "all" leaves them off (input-motion logs every pointer motion).
25-var categories = map[string]bool{"input-motion": true}25+// Naming one turns on debug for its component.
26+var categories = map[string]string{"input-motion": "input"}
26 27
27 type debugKey struct{}28 type debugKey struct{}
28 type levelKey struct{}29 type levelKey struct{}
@@ -38,7 +39,7 @@ func ParseDebug(value string) (map[string]bool, error) {
38 selected[name] = true39 selected[name] = true
39 continue40 continue
40 }41 }
41- if !components[name] && !categories[name] {42+ if _, ok := categories[name]; !components[name] && !ok {
42 return nil, fmt.Errorf("invalid debug component %q", name)43 return nil, fmt.Errorf("invalid debug component %q", name)
43 }44 }
44 selected[name] = true45 selected[name] = true
@@ -130,6 +131,11 @@ func For(ctx context.Context, component string) zerowrap.Logger {
130 if selected["all"] || selected[component] {131 if selected["all"] || selected[component] {
131 level = zerolog.DebugLevel132 level = zerolog.DebugLevel
132 }133 }
134+ for name, owner := range categories {
135+ if selected[name] && owner == component {
136+ level = zerolog.DebugLevel
137+ }
138+ }
133 log = zerowrap.Logger{Logger: log.Level(level)}139 log = zerowrap.Logger{Logger: log.Level(level)}
134 return log140 return log
135 }141 }
M internal/logging/logging_test.go +22 -0
@@ -84,6 +84,28 @@ func splitLines(data []byte) [][]byte {
8484 return lines
8585 }
8686
87+// A category alone raises its component to debug, so its lines are written.
88+func TestCategoryEnablesComponentDebug(t *testing.T) {
89+ t.Setenv("XDG_STATE_HOME", t.TempDir())
90+ ctx, closeLog, err := Open(context.Background(), "info", "input-motion")
91+ if err != nil {
92+ t.Fatal(err)
93+ }
94+ input, core := For(ctx, "input"), For(ctx, "core")
95+ input.Debug().Msg("motion")
96+ core.Debug().Msg("hidden")
97+ if err := closeLog(); err != nil {
98+ t.Fatal(err)
99+ }
100+ data, err := os.ReadFile(filepath.Join(os.Getenv("XDG_STATE_HOME"), "nefertty", "runs", "latest.log"))
101+ if err != nil {
102+ t.Fatal(err)
103+ }
104+ if lines := splitLines(data); len(lines) != 1 || !bytes.Contains(lines[0], []byte(`"motion"`)) {
105+ t.Fatalf("got %q", data)
106+ }
107+}
108+
87109 // Narrow categories are on only when named, never through "all".
88110 func TestEnabledCategories(t *testing.T) {
89111 for _, tc := range []struct {
@@ -84,6 +84,28 @@ func splitLines(data []byte) [][]byte {
84 return lines84 return lines
85 }85 }
86 86
87+// A category alone raises its component to debug, so its lines are written.
88+func TestCategoryEnablesComponentDebug(t *testing.T) {
89+ t.Setenv("XDG_STATE_HOME", t.TempDir())
90+ ctx, closeLog, err := Open(context.Background(), "info", "input-motion")
91+ if err != nil {
92+ t.Fatal(err)
93+ }
94+ input, core := For(ctx, "input"), For(ctx, "core")
95+ input.Debug().Msg("motion")
96+ core.Debug().Msg("hidden")
97+ if err := closeLog(); err != nil {
98+ t.Fatal(err)
99+ }
100+ data, err := os.ReadFile(filepath.Join(os.Getenv("XDG_STATE_HOME"), "nefertty", "runs", "latest.log"))
101+ if err != nil {
102+ t.Fatal(err)
103+ }
104+ if lines := splitLines(data); len(lines) != 1 || !bytes.Contains(lines[0], []byte(`"motion"`)) {
105+ t.Fatalf("got %q", data)
106+ }
107+}
108+
87 // Narrow categories are on only when named, never through "all".109 // Narrow categories are on only when named, never through "all".
88 func TestEnabledCategories(t *testing.T) {110 func TestEnabledCategories(t *testing.T) {
89 for _, tc := range []struct {111 for _, tc := range []struct {

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 26

Tags 10

↑↓ moveenter openesc close