Files
gf/os/glog/glog_z_example_test.go

24 lines
576 B
Go
Raw Permalink Normal View History

2021-01-17 21:46:25 +08:00
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
2020-06-08 20:21:35 +08:00
//
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file,
// You can obtain one at https://github.com/gogf/gf.
package glog_test
import (
"context"
2021-11-15 20:31:16 +08:00
2021-10-11 21:41:56 +08:00
"github.com/gogf/gf/v2/frame/g"
2020-06-08 20:21:35 +08:00
)
2023-02-08 19:08:10 +08:00
func ExampleContext() {
2020-06-08 20:21:35 +08:00
ctx := context.WithValue(context.Background(), "Trace-Id", "123456789")
2021-09-27 21:27:24 +08:00
g.Log().Error(ctx, "runtime error")
2020-06-08 20:21:35 +08:00
// May Output:
// 2020-06-08 20:17:03.630 [ERRO] {Trace-Id: 123456789} runtime error
// Stack:
// ...
}