Documentation ¶
Overview ¶
Copyright 2023, DASH-Industry Forum. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE.md file.
Copyright 2023, DASH-Industry Forum. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE.md file.
Index ¶
- Constants
- Variables
- func GetRequestID(r *http.Request) string
- func InitSlog(level string, logFormat string) error
- func LogLevel() string
- func LogLevelGet(w http.ResponseWriter, r *http.Request)
- func LogLevelSet(w http.ResponseWriter, r *http.Request)
- func SetLogLevel(level string) error
- func SlogMiddleWare(l *slog.Logger) func(next http.Handler) http.Handler
- func SubLoggerWithRequestID(l *slog.Logger, r *http.Request) *slog.Logger
- type Route
Constants ¶
const ( LogText string = "text" LogJSON string = "json" LogPretty string = "pretty" LogDiscard string = "discard" )
Different types of logging
Variables ¶
var LogFormats = []string{LogText, LogJSON, LogPretty, LogDiscard}
LogFormats returns the allowed log formats.
var LogLevels = []string{"DEBUG", "INFO", "WARN", "ERROR"}
LogLevels returns the allowed log levels.
var LogRoutes = [2]Route{ {"GET", "/loglevel", LogLevelGet}, {"POST", "/loglevel", LogLevelSet}, }
Functions ¶
func InitSlog ¶ added in v1.0.0
InitSlog initializes the global slog logger.
level and logLevel determine where the logs go and what format is used.
func LogLevelGet ¶
func LogLevelGet(w http.ResponseWriter, r *http.Request)
LogLevelGet handles loglevel GET request
func LogLevelSet ¶
func LogLevelSet(w http.ResponseWriter, r *http.Request)
LogLevelSet sets the loglevel from a posted form Can be triggered like curl -F level=debug <server>/loglevel
func SlogMiddleWare ¶ added in v1.0.0
SlogMiddleWare logs access and converts panic to stack traces.