File tree Expand file tree Collapse file tree 5 files changed +299
-234
lines changed Expand file tree Collapse file tree 5 files changed +299
-234
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,20 @@ func New() (ctx *Context) {
48
48
return
49
49
}
50
50
51
+ func (ctx * Context ) Copy () * Context {
52
+ newContext := new (Context )
53
+ newContext .Trace = ctx .Trace
54
+ newContext .index = ctx .index
55
+ newContext .level = ctx .level
56
+ newContext .fields = make (map [string ]interface {})
57
+
58
+ for k , v := range ctx .fields {
59
+ newContext .fields [k ] = v
60
+ }
61
+
62
+ return newContext
63
+ }
64
+
51
65
func (ctx * Context ) Derived () (derived * Context ) {
52
66
ctx .index += 1
53
67
derived = New ()
@@ -56,8 +70,10 @@ func (ctx *Context) Derived() (derived *Context) {
56
70
}
57
71
58
72
func (ctx * Context ) Level (level int ) * Context {
59
- ctx .level = convertLevel (level )
60
- return ctx
73
+ newContext := ctx .Copy ()
74
+ newContext .level = convertLevel (level )
75
+
76
+ return newContext
61
77
}
62
78
63
79
func (ctx * Context ) Field (name string , value interface {}) * Context {
You can’t perform that action at this time.
0 commit comments