Documentation
¶
Overview ¶
Package wlog provides colorized logging utilities for HTTP requests and responses.
Index ¶
- Variables
- func ColorStatus(status int) string
- func ColorTime(dur time.Duration) string
- func FromContext(ctx context.Context) *zerolog.Logger
- func FromContextOk(ctx context.Context) (*zerolog.Logger, bool)
- func GlobalLogger() *zerolog.Logger
- func MarshalStack(err error) any
- func NewZeroLogger(opts ...CreateOpts) *zerolog.Logger
- func NopLogger() zerolog.Logger
- func PrintStackTrace()
- func RouteColor(r *http.Request) string
- func SetLogLevel(level zerolog.Level)
- func ShowStackTrace()
- func WithContext(ctx context.Context, l *zerolog.Logger) context.Context
- type CreateOpts
- type ErrUnwrapHook
- type WLConsoleLogger
Constants ¶
This section is empty.
Variables ¶
var ( // RED is the ANSI escape code for red text. RED = "\u001b[31m" // BLUE is the ANSI escape code for green text. BLUE = "\u001b[32m" // YELLOW is the ANSI escape code for yellow text. YELLOW = "\u001b[33m" // ORANGE is the ANSI escape code for cyan text. ORANGE = "\u001b[36m" // RESET is the ANSI escape code to reset text formatting. RESET = "\u001B[0m" )
var ( // StackSourceFileName is the key for the source file name in stack traces. StackSourceFileName = "source" // StackSourceLineName is the key for the line number in stack traces. StackSourceLineName = "line" // StackSourceFunctionName is the key for the function name in stack traces. StackSourceFunctionName = "func" )
Functions ¶
func ColorStatus ¶
ColorStatus returns an HTTP status code string with color formatting based on the status value.
func ColorTime ¶
ColorTime returns a duration string with color formatting based on the duration length.
func FromContext ¶
FromContext extracts a logger from the context, or returns the global logger.
func FromContextOk ¶
FromContextOk extracts a logger from the context and returns whether it was present.
func GlobalLogger ¶
GlobalLogger returns a copy of the global logger instance. The returned logger is safe to use concurrently and can have UpdateContext called on it without racing with other goroutines.
func MarshalStack ¶
MarshalStack extracts and marshals the stack trace from an error.
func NewZeroLogger ¶
func NewZeroLogger(opts ...CreateOpts) *zerolog.Logger
NewZeroLogger creates a new zerolog logger with the given options.
func PrintStackTrace ¶
func PrintStackTrace()
PrintStackTrace captures and prints the current stack trace.
func RouteColor ¶
RouteColor returns the route pattern for the request, highlighting unknown routes in red.
func ShowStackTrace ¶
func ShowStackTrace()
ShowStackTrace is a placeholder for stack trace visualization.
Types ¶
type CreateOpts ¶
CreateOpts configures logging options.
type ErrUnwrapHook ¶
type ErrUnwrapHook struct{}
ErrUnwrapHook is a zerolog hook for unwrapping errors.
type WLConsoleLogger ¶
type WLConsoleLogger struct {
// contains filtered or unexported fields
}
WLConsoleLogger is a development console logger with colored output.