Skip to content

Commit dadce2e

Browse files
committed
feat: nested map param
1 parent cc0edbc commit dadce2e

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

examples/params_test.go

+5
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ func TestNested(t *testing.T) {
4949

5050
logger.Debug("123", typedlogs.NestedParam("abc"))
5151
logger.Debug("456", typedlogs.NestedStructParam("abc"))
52+
53+
logger.Debug("456", typelog.NestedMap("smth", map[string]any{
54+
"a": 1,
55+
"b": 2,
56+
}))
5257
}
5358

5459
func TestCopyingLoggers(t *testing.T) {

typelog/logtypes.go

+6
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,9 @@ func Map(value map[string]any) LogType {
147147
c.Append(TurnMapToAttrs(value)...)
148148
}
149149
}
150+
151+
func NestedMap(key string, value map[string]any) LogType {
152+
return func(c *LogAtrs) {
153+
c.Append(Group(key, TurnMapToAttrs(value)...))
154+
}
155+
}

0 commit comments

Comments
 (0)