logger

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseLevel

func ParseLevel(level string) slog.Level

Types

type Config

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

Config is used to parse CLI flags related to logging

func NewConfig

func NewConfig(flag *flag.FlagSet, appName string) *Config

NewConfig prepares a new configuration for parsing CLI flags

func (*Config) Level

func (cfg *Config) Level() string

Level exposes the configured log level as a string. If a process level logging configuration has been specified it will override the generic "gm_log_level"

func (*Config) Logger

func (cfg *Config) Logger(w io.Writer, keyvals ...interface{}) (*L, error)

Logger gets the logger

type ElasticLogger

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

ElasticLogger wraps a L and satisfies the interface required by https://godoc.org/github.com/olivere/elastic#Logger

func NewElasticLogger

func NewElasticLogger(l *L) *ElasticLogger

NewElasticLogger creates a new ElasticSearch compatible logger that wraps l

func (*ElasticLogger) Printf

func (el *ElasticLogger) Printf(format string, v ...interface{})

Printf logs the message to the wrapped logger at the debug level

type HTTPLogger

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

HTTPLogger wraps a L and satisfys the interface required by https://godoc.org/github.com/ernesto-jimenez/httplogger#HTTPLogger

func NewHTTPLogger

func NewHTTPLogger(l *L, level string) *HTTPLogger

NewHTTPLogger creates a new HTTPLogger. level is the log level at which you want your HTTP requests logged at.

func (*HTTPLogger) LogRequest

func (h *HTTPLogger) LogRequest(*http.Request)

LogRequest doesn't do anything since we'll be logging replies only

func (*HTTPLogger) LogResponse

func (h *HTTPLogger) LogResponse(req *http.Request, res *http.Response, err error, duration time.Duration)

LogResponse logs path, host, status code and duration in milliseconds

type L

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

func Default

func Default() *L

Default returns a default logger implementation

func New

func New(w io.Writer, name, level string, keyvals ...any) *L

New initializes a new logger. If w is nil, logs will be sent to stdout.

func Silence

func Silence() *L

func (*L) Debug

func (l *L) Debug(msg any, keyvals ...any)

Debug logs a message at the debug level

func (*L) Err

func (l *L) Err(msg any, keyvals ...any)

Err logs a message at the error level

func (*L) Fatal

func (l *L) Fatal(msg any, keyvals ...any)

Fatal logs a message at the fatal level and also exits the program by calling os.Exit

func (*L) Info

func (l *L) Info(msg any, keyvals ...any)

Info logs a message at the info level

func (*L) New

func (l *L) New(name string) *L

New returns a sub-logger with the name appended to the existing logger's source

func (*L) Warn

func (l *L) Warn(msg any, keyvals ...any)

Warn logs a message at the warning level

func (*L) With

func (l *L) With(keyvals ...any) *L

With returns a logger with the keyvals appended to the existing logger

type NSQLogger

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

NSQLogger is a thin wrapper around our the Logger that bends it to the interface uses by the go-nsq library

func NewNSQLogger

func NewNSQLogger(l *L, level string) *NSQLogger

NewNSQLogger initializes a new Logger

func (*NSQLogger) Output

func (l *NSQLogger) Output(calldepth int, s string) error

Output writes the message to our logger

type StripeLogger

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

StripeLogger is a thin wrapper around our the Logger that bends it to the interface uses by the stripe library

func NewStripeLogger

func NewStripeLogger(l *L, level string) *StripeLogger

NewStripeLogger initializes a new Logger

func (*StripeLogger) Printf

func (l *StripeLogger) Printf(format string, v ...interface{})

Printf prints a message to the logs

Jump to

Keyboard shortcuts

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