github.com/gogf/gf@v1.16.9/os/glog/glog_z_example_test.go (about) 1 // Copyright GoFrame Author(https://goframe.org). All Rights Reserved. 2 // 3 // This Source Code Form is subject to the terms of the MIT License. 4 // If a copy of the MIT was not distributed with this file, 5 // You can obtain one at https://github.com/gogf/gf. 6 7 package glog_test 8 9 import ( 10 "context" 11 "github.com/gogf/gf/frame/g" 12 ) 13 14 func Example_context() { 15 ctx := context.WithValue(context.Background(), "Trace-Id", "123456789") 16 g.Log().Ctx(ctx).Error("runtime error") 17 18 // May Output: 19 // 2020-06-08 20:17:03.630 [ERRO] {Trace-Id: 123456789} runtime error 20 // Stack: 21 // ... 22 }