Skip to content

Commit d8c5704

Browse files
committed
Add back ValueFunc
1 parent 0ac48ad commit d8c5704

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

slog.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ type Value interface {
2525
LogValue() interface{}
2626
}
2727

28+
// ValueFunc is a convenient function wrapper around Value.
29+
type ValueFunc func() interface{}
30+
31+
// LogValue implements Value.
32+
func (v ValueFunc) LogValue() interface{} {
33+
return v()
34+
}
35+
2836
type componentField string
2937

3038
func (c componentField) LogKey() string { panic("never called") }

slogval/reflect.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616
// that would like to only use the reflection based
1717
// converter for itself and ignore interfaces like error
1818
// or fmt.Stringer.
19-
// TODO add back ValueFunc
2019
type Reflector interface {
2120
LogWithReflect()
2221
}

0 commit comments

Comments
 (0)