Documentation ¶
Index ¶
- Constants
- Variables
- func GetLogLevel() string
- func GetRequestID(r *http.Request) string
- func LogLevelGet(w http.ResponseWriter, r *http.Request)
- func LogLevelSet(w http.ResponseWriter, r *http.Request)
- func LoggerWithTopic(topic string) *zerolog.Logger
- func SetLogFile(filename string) (*os.File, error)
- func SetLogLevel(level string) error
- func SubLoggerWithRequestID(r *http.Request) *zerolog.Logger
- func SubLoggerWithRequestIDAndTopic(r *http.Request, topic string) *zerolog.Logger
- func SubLoggerWithSpecificLevel(lg *zerolog.Logger, level string) *zerolog.Logger
- func SubLoggerWithString(key string, val string) *zerolog.Logger
- func SubLoggerWithTopic(lg *zerolog.Logger, topic string) *zerolog.Logger
- func ZerologMiddleware(logger *zerolog.Logger) func(next http.Handler) http.Handler
- type Logger
- type Route
Constants ¶
View Source
const ( LogConsolePretty string = "consolepretty" LogJSON string = "json" LogDiscard string = "discard" LogJournald string = "journald" )
Different types of logging
Variables ¶
View Source
var LogFormats = []string{LogJSON, LogConsolePretty, LogJournald, LogDiscard}
View Source
var LogFormatsCommandLine = []string{LogJSON, LogConsolePretty, LogDiscard}
View Source
var LogLevels = []string{"trace", "debug", "info", "warn", "error", "fatal", "panic"}
View Source
var LogRoutes = [2]Route{ {"GET", "/loglevel", LogLevelGet}, {"POST", "/loglevel", LogLevelSet}, }
Functions ¶
func LogLevelGet ¶
func LogLevelGet(w http.ResponseWriter, r *http.Request)
LogLevelGet - Handle loglevel GET request
func LogLevelSet ¶
func LogLevelSet(w http.ResponseWriter, r *http.Request)
LogLevelSet - Handle loglevel POST request
func LoggerWithTopic ¶
LoggerWithTopic creates a top-level logger with topic field.
func SetLogFile ¶
SetLogFile creates a new global logger that writes to a file.
func SubLoggerWithRequestID ¶
SubLoggerWithRequestID creates a new sub-logger with request_id field.
func SubLoggerWithRequestIDAndTopic ¶
SubLoggerWithRequestIDAndTopic creates a new sub-logger with request_id and topic fields.
func SubLoggerWithSpecificLevel ¶
SubLogger creates a new sub-logger with a specific log level.
func SubLoggerWithString ¶
SubLogger create a new sub-logger with a specific key, value field.
func SubLoggerWithTopic ¶
SubLoggerWithTopic creates sub-logger with topic field.
Types ¶
type Logger ¶
func GetGlobalLogger ¶
func GetGlobalLogger() *Logger
GetGlobalLogger returns the global logger instance.
Click to show internal directories.
Click to hide internal directories.