logging

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2026 License: GPL-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AuthStatusSuccess       = "success"
	AuthStatusFailed        = "failed"
	AuthStatusNone          = "none"
	AuthStatusSkipped       = "skipped"
	RequestIDHeader         = "X-Request-ID"
	AuthStatusContextKey    = "auth_status"
	AuthErrorContextKey     = "auth_error"
	AuthTokenHashContextKey = "auth_token_hash"
)

Variables

Functions

func ExtractBearerToken

func ExtractBearerToken(authHeader string) string

func HashToken

func HashToken(token string) string

func RegisterLoggerShutdown

func RegisterLoggerShutdown(lc fx.Lifecycle, logger *Logger)

func RegisterShutdown

func RegisterShutdown(lc fx.Lifecycle, service *Service)

func RequestLoggingMiddleware

func RequestLoggingMiddleware(service *Service) echo.MiddlewareFunc

func SetAuthFailure

func SetAuthFailure(c echo.Context, reason string)

func SetAuthSkipped

func SetAuthSkipped(c echo.Context)

func SetAuthSuccess

func SetAuthSuccess(c echo.Context, token string)

Types

type Logger

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

func NewLogger

func NewLogger(logLevel string) (*Logger, error)

func NewLoggerFromConfig

func NewLoggerFromConfig(cfg *config.Config) (*Logger, error)

func (*Logger) Debug

func (l *Logger) Debug(msg string, fields ...zap.Field)

func (*Logger) Error

func (l *Logger) Error(msg string, fields ...zap.Field)

func (*Logger) Fatal

func (l *Logger) Fatal(msg string, fields ...zap.Field)

func (*Logger) GetZap

func (l *Logger) GetZap() *zap.Logger

func (*Logger) Info

func (l *Logger) Info(msg string, fields ...zap.Field)

func (*Logger) Panic

func (l *Logger) Panic(msg string, fields ...zap.Field)

func (*Logger) Sync

func (l *Logger) Sync() error

func (*Logger) Warn

func (l *Logger) Warn(msg string, fields ...zap.Field)

func (*Logger) With

func (l *Logger) With(fields ...zap.Field) *Logger

type RequestLogEntry

type RequestLogEntry struct {
	Timestamp     string            `json:"timestamp"`
	RequestID     string            `json:"request_id"`
	SourceIP      string            `json:"source_ip"`
	Method        string            `json:"method"`
	Path          string            `json:"path"`
	UserAgent     string            `json:"user_agent,omitempty"`
	AuthStatus    string            `json:"auth_status"`
	AuthError     string            `json:"auth_error,omitempty"`
	AuthTokenHash string            `json:"auth_token_hash,omitempty"`
	StatusCode    int               `json:"status_code"`
	ResponseSize  int64             `json:"response_size"`
	LatencyMs     float64           `json:"latency_ms"`
	Error         string            `json:"error,omitempty"`
	StackName     string            `json:"stack_name,omitempty"`
	ContainerName string            `json:"container_name,omitempty"`
	Operation     string            `json:"operation,omitempty"`
	OperationID   string            `json:"operation_id,omitempty"`
	FilePath      string            `json:"file_path,omitempty"`
	Metadata      map[string]string `json:"metadata,omitempty"`
}

func NewRequestLogEntry

func NewRequestLogEntry() *RequestLogEntry

type Service

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

func NewService

func NewService(enabled bool, logFilePath string, maxSizeBytes int64) (*Service, error)

func NewServiceFromConfig

func NewServiceFromConfig(cfg *config.Config) (*Service, error)

func (*Service) Close

func (s *Service) Close() error

func (*Service) LogRequest

func (s *Service) LogRequest(entry *RequestLogEntry)

Jump to

Keyboard shortcuts

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