removed add loggerContextAttr
Some checks failed
automerge / automerge (pull_request) Has been skipped
dependabot-automerge / automerge (pull_request) Has been skipped
autoapprove / autoapprove (pull_request) Successful in 7s
codeql / analyze (go) (pull_request) Has been cancelled
prbuild / test (pull_request) Has been cancelled
prbuild / lint (pull_request) Has been cancelled
Some checks failed
automerge / automerge (pull_request) Has been skipped
dependabot-automerge / automerge (pull_request) Has been skipped
autoapprove / autoapprove (pull_request) Successful in 7s
codeql / analyze (go) (pull_request) Has been cancelled
prbuild / test (pull_request) Has been cancelled
prbuild / lint (pull_request) Has been cancelled
This commit is contained in:
parent
f85cbcdca2
commit
aee2908ed1
12
.gitignore
vendored
12
.gitignore
vendored
@ -1,3 +1,9 @@
|
|||||||
|
# Develop tools
|
||||||
|
/.vscode/
|
||||||
|
/.idea/
|
||||||
|
.idea
|
||||||
|
.vscode
|
||||||
|
|
||||||
# Binaries for programs and plugins
|
# Binaries for programs and plugins
|
||||||
*.exe
|
*.exe
|
||||||
*.exe~
|
*.exe~
|
||||||
@ -5,6 +11,12 @@
|
|||||||
*.so
|
*.so
|
||||||
*.dylib
|
*.dylib
|
||||||
|
|
||||||
|
# Folders
|
||||||
|
_obj
|
||||||
|
_test
|
||||||
|
_build
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
# Test binary, built with `go test -c`
|
# Test binary, built with `go test -c`
|
||||||
*.test
|
*.test
|
||||||
|
|
||||||
|
15
requestid.go
15
requestid.go
@ -2,26 +2,13 @@ package requestid // import "go.unistack.org/micro-wrapper-requestid/v3"
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"net/textproto"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"go.unistack.org/micro/v3/client"
|
"go.unistack.org/micro/v3/client"
|
||||||
"go.unistack.org/micro/v3/logger"
|
|
||||||
"go.unistack.org/micro/v3/metadata"
|
"go.unistack.org/micro/v3/metadata"
|
||||||
"go.unistack.org/micro/v3/server"
|
"go.unistack.org/micro/v3/server"
|
||||||
"go.unistack.org/micro/v3/util/id"
|
"go.unistack.org/micro/v3/util/id"
|
||||||
|
"net/textproto"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
|
||||||
requestIDLog := strings.ToLower(DefaultMetadataKey)
|
|
||||||
logger.DefaultContextAttrFuncs = append(logger.DefaultContextAttrFuncs, func(ctx context.Context) []interface{} {
|
|
||||||
if v, ok := ctx.Value(XRequestIDKey{}).(string); ok {
|
|
||||||
return []interface{}{requestIDLog, v}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
type XRequestIDKey struct{}
|
type XRequestIDKey struct{}
|
||||||
|
|
||||||
// DefaultMetadataKey contains metadata key
|
// DefaultMetadataKey contains metadata key
|
||||||
|
Loading…
x
Reference in New Issue
Block a user