mirror of
https://github.com/hanzoai/traces.git
synced 2026-10-30 18:20:41 +00:00
* Upgrade dskit dependency to latest main * Revert upgrades to otel dependencies * rm kuberesolver/v5/README.md * Add kuberesolver/v5/README.md * no touch crlf?
27 lines
612 B
Go
27 lines
612 B
Go
// Provenance-includes-location: https://github.com/weaveworks/common/blob/main/user/logging.go
|
|
// Provenance-includes-license: Apache-2.0
|
|
// Provenance-includes-copyright: Weaveworks Ltd.
|
|
|
|
package user
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/go-kit/log"
|
|
)
|
|
|
|
// LogWith returns user and org information from the context as log fields.
|
|
func LogWith(ctx context.Context, logger log.Logger) log.Logger {
|
|
userID, err := ExtractUserID(ctx)
|
|
if err == nil {
|
|
logger = log.With(logger, "userID", userID)
|
|
}
|
|
|
|
orgID, err := ExtractOrgID(ctx)
|
|
if err == nil {
|
|
logger = log.With(logger, "orgID", orgID)
|
|
}
|
|
|
|
return logger
|
|
}
|