server

package
v1.0.0-beta.80 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultStructuredLoggerOptions = &StructuredLoggerOptions{
	SkipPaths:       []string{},
	LogLevel:        slog.LevelDebug,
	TimeFieldFormat: time.RFC3339,
	TimeFieldName:   "timestamp",
}

Functions

func NewStructuredLogger

func NewStructuredLogger(handler slog.Handler, options *StructuredLoggerOptions) func(next http.Handler) http.Handler

Types

type Config

type Config struct {
	RouterConfig router.Config
	RouterHook   func(r chi.Router)
}

type Server

type Server struct {
	chi.Router
}

func NewServer

func NewServer(config *Config) (*Server, error)

type ServerLogger

type ServerLogger struct{}

type StructuredLogger

type StructuredLogger struct {
	Logger  slog.Handler
	Options *StructuredLoggerOptions
}

func (*StructuredLogger) NewLogEntry

func (l *StructuredLogger) NewLogEntry(r *http.Request) middleware.LogEntry

type StructuredLoggerEntry

type StructuredLoggerEntry struct {
	// contains filtered or unexported fields
}

func (*StructuredLoggerEntry) Panic

func (e *StructuredLoggerEntry) Panic(v interface{}, stack []byte)

func (*StructuredLoggerEntry) Write

func (e *StructuredLoggerEntry) Write(status, bytes int, header http.Header, elapsed time.Duration, extra interface{})

type StructuredLoggerOptions

type StructuredLoggerOptions struct {
	// LogLevel defines the minimum level of severity that app should log.
	LogLevel slog.Level

	// SkipPaths defines a list of paths that should not be logged.
	SkipPaths []string

	// TimeFieldFormat defines the time format of the Time field, defaulting to "time.RFC3339Nano" see options at:
	// https://pkg.go.dev/time#pkg-constants
	TimeFieldFormat string

	// TimeFieldName sets the field name for the time field.
	// Some providers parse and search for different field names.
	TimeFieldName string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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