Documentation
¶
Index ¶
- Constants
- Variables
- func ExtractBearerToken(authHeader string) string
- func HashToken(token string) string
- func RegisterLoggerShutdown(lc fx.Lifecycle, logger *Logger)
- func RegisterShutdown(lc fx.Lifecycle, service *Service)
- func RequestLoggingMiddleware(service *Service) echo.MiddlewareFunc
- func SetAuthFailure(c echo.Context, reason string)
- func SetAuthSkipped(c echo.Context)
- func SetAuthSuccess(c echo.Context, token string)
- type Logger
- func (l *Logger) Debug(msg string, fields ...zap.Field)
- func (l *Logger) Error(msg string, fields ...zap.Field)
- func (l *Logger) Fatal(msg string, fields ...zap.Field)
- func (l *Logger) GetZap() *zap.Logger
- func (l *Logger) Info(msg string, fields ...zap.Field)
- func (l *Logger) Panic(msg string, fields ...zap.Field)
- func (l *Logger) Sync() error
- func (l *Logger) Warn(msg string, fields ...zap.Field)
- func (l *Logger) With(fields ...zap.Field) *Logger
- type RequestLogEntry
- type Service
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 ¶
View Source
var Module = fx.Options( fx.Provide(NewServiceFromConfig), fx.Provide(NewLoggerFromConfig), fx.Invoke(RegisterShutdown), fx.Invoke(RegisterLoggerShutdown), )
Functions ¶
func ExtractBearerToken ¶
func RegisterLoggerShutdown ¶
func RegisterShutdown ¶
func RequestLoggingMiddleware ¶
func RequestLoggingMiddleware(service *Service) echo.MiddlewareFunc
func SetAuthFailure ¶
func SetAuthSkipped ¶
func SetAuthSuccess ¶
Types ¶
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 (*Service) LogRequest ¶
func (s *Service) LogRequest(entry *RequestLogEntry)
Click to show internal directories.
Click to hide internal directories.