logger

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2024 License: Apache-2.0 Imports: 10 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"
	// CommandLine is the component type for the Ratify command line.
	CommandLine componentType = "commandLine"
	// 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"
	// KeyManagementProvider is the component type for key management provider.
	KeyManagementProvider componentType = "keyManagementProvider"
	// 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"
	// Plugin is the component type for plugin.
	Plugin componentType = "plugin"
)

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 GetTraceID

func GetTraceID(ctx context.Context) string

GetTraceID returns the trace ID from the context.

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