Documentation ¶
Index ¶
- Constants
- Variables
- func CheckFatal(location string, err error)
- func ContextWithHeaderMap(ctx context.Context, headerMap map[string]string) context.Context
- func ContextWithHeaderMapFromMetadata(ctx context.Context, md metadata.MD) context.Context
- func HeaderMapFromContext(ctx context.Context) map[string]string
- func InitLogger(cfg *server.Config)
- func InjectHeadersIntoHTTPRequest(headerMap map[string]string, request *http.Request)
- func LevelFilter(l string) level.Option
- func NewPrometheusLogger(l logging.Level, format logging.Format) (log.Logger, error)
- func WarnExperimentalUse(feature string)
- func WithContext(ctx context.Context, l kitlog.Logger) kitlog.Logger
- func WithSourceIPs(sourceIPs string, l log.Logger) log.Logger
- func WithTraceID(traceID string, l kitlog.Logger) kitlog.Logger
- func WithUserID(userID string, l kitlog.Logger) kitlog.Logger
- type PrometheusLogger
Constants ¶
const (
HeaderPropagationStringForRequestLogging string = "x-http-header-forwarding-logging"
)
Variables ¶
var ( // Logger is a shared go-kit logger. // TODO: Change all components to take a non-global logger via their constructors. // Prefer accepting a non-global logger as an argument. Logger = kitlog.NewNopLogger() )
Functions ¶
func CheckFatal ¶
CheckFatal prints an error and exits with error code 1 if err is non-nil
func ContextWithHeaderMap ¶ added in v1.14.0
func ContextWithHeaderMapFromMetadata ¶ added in v1.14.0
func HeaderMapFromContext ¶ added in v1.14.0
func InitLogger ¶
InitLogger initialises the global gokit logger (util_log.Logger) and overrides the default logger for the server.
func InjectHeadersIntoHTTPRequest ¶ added in v1.14.0
InjectHeadersIntoHTTPRequest injects the logging header map from the context into the request headers.
func LevelFilter ¶ added in v1.11.0
TODO(dannyk): remove once weaveworks/common updates to go-kit/log
-> we can then revert to using Level.Gokit
func NewPrometheusLogger ¶
NewPrometheusLogger creates a new instance of PrometheusLogger which exposes Prometheus counters for various log levels.
func WarnExperimentalUse ¶
func WarnExperimentalUse(feature string)
WarnExperimentalUse logs a warning and increments the experimental features metric.
func WithContext ¶
WithContext returns a Logger that has information about the current user in its details.
e.g.
log := util.WithContext(ctx) log.Errorf("Could not chunk chunks: %v", err)
func WithSourceIPs ¶
WithSourceIPs returns a Logger that has information about the source IPs in its details.
func WithTraceID ¶
WithTraceID returns a Logger that has information about the traceID in its details.
Types ¶
type PrometheusLogger ¶
type PrometheusLogger struct {
// contains filtered or unexported fields
}
PrometheusLogger exposes Prometheus counters for each of go-kit's log levels.
func (*PrometheusLogger) Log ¶
func (pl *PrometheusLogger) Log(kv ...interface{}) error
Log increments the appropriate Prometheus counter depending on the log level.