logger

package
v0.0.0-...-ddd1a7f Latest Latest
Warning

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

Go to latest
Published: May 2, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LogLevelError = "error"
	LogLevelWarn  = "warn"
	LogLevelInfo  = "info"
	LogLevelDebug = "debug"
)

Variables

This section is empty.

Functions

func HTTPLog

func HTTPLog(log Interface, hlp HTTPLogParams, logTitle string)

func WithBaseInfo

func WithBaseInfo(logger Interface, appName, appPort string)

Types

type HTTPLogParams

type HTTPLogParams struct {
	StatusCode      int
	Duration        int64
	Method          string
	RequestID       string
	Link            string
	UserAgent       string
	Error           error
	ErrorCallerInfo string
}

type Interface

type Interface interface {
	// Debugf uses fmt.Sprintf to construct and log a message at DEBUG level
	Debug(message string, args ...any)

	// Errorf uses fmt.Sprintf to construct and log a message at ERROR level
	Error(message string, args ...any)

	// Fatalf uses fmt.Sprintf to construct and log a message at FATAL level
	Fatal(message string, args ...any)

	// Infof uses fmt.Sprintf to construct and log a message at INFO level
	Info(message string, args ...any)

	// Warnf uses fmt.Sprintf to construct and log a message at WARN level
	Warn(message string, args ...any)

	// With attributes
	With(args ...any)
}

Interface is a logger that supports log levels, context and structured logging.

type SlogLogger

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

func NewSlogLogger

func NewSlogLogger(level, logDisplayType string, output io.Writer) *SlogLogger

func (*SlogLogger) Debug

func (l *SlogLogger) Debug(msg string, args ...any)

func (*SlogLogger) Error

func (l *SlogLogger) Error(msg string, args ...any)

func (*SlogLogger) Fatal

func (l *SlogLogger) Fatal(msg string, args ...any)

func (*SlogLogger) Info

func (l *SlogLogger) Info(msg string, args ...any)

func (*SlogLogger) Warn

func (l *SlogLogger) Warn(msg string, args ...any)

func (*SlogLogger) With

func (l *SlogLogger) With(args ...any)

Jump to

Keyboard shortcuts

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