logger

package
v1.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 2, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ContextKeyTraceID is the context key for the trace ID.
	ContextKeyTraceID = ContextKey("trace-id")
	// ContextKeyComponentType is the context key for the component type.
	ContextKeyComponentType = ContextKey("component-type")
	// Executor is the component type for the executor.
	Executor componentType = "executor"
	// Server is the component type for the Ratify http server.
	Server componentType = "server"
	// ReferrerStore is the component type for the referrer store.
	ReferrerStore componentType = "referrerStore"
	// Cache is the component type for the cache.
	Cache componentType = "cache"
	// CertProvider is the component type for certificate provider.
	CertProvider componentType = "certificateProvider"
	// AuthProvider is the component type for auth provider.
	AuthProvider componentType = "authProvider"
	// PolicyProvider is the component type for policy provider.
	PolicyProvider componentType = "policyProvider"
	// Verifier is the component type for verifier.
	Verifier componentType = "verifier"
)

Variables

This section is empty.

Functions

func GetLogger

func GetLogger(ctx context.Context, opt Option) dcontext.Logger

GetLogger returns a logger with provided values.

func InitContext

func InitContext(ctx context.Context, r *http.Request) context.Context

InitContext initializes the context with required loggers for a request.

func InitLogConfig

func InitLogConfig(config Config) error

InitLogConfig initializes log configuration for the server.

func SetTraceIDHeader

func SetTraceIDHeader(ctx context.Context, header http.Header) http.Header

SetTraceIDHeader sets the trace ID in the http header.

Types

type Config

type Config struct {
	Formatter      string                 `json:"formatter,omitempty"`
	RequestHeaders map[string]interface{} `json:"requestHeaders"`
}

Config is the configuration for the logger.

type ContextKey

type ContextKey string

ContextKey defines the key type used for the context.

func (ContextKey) String

func (c ContextKey) String() string

String returns the string representation of the context key.

type Option

type Option struct {
	ComponentType componentType
}

Option is used for each component to add customized fields to the logger.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL