common

package
v0.0.0-...-9275613 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2023 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBadEnvironment = errors.New("bad environment")
View Source
var ErrEnvironmentBadValue = errors.New("bad env value")
View Source
var ErrEnvironmentKeyMissing = errors.New("missing env var")
View Source
var ErrLocked = errors.New("mutex is locked")
View Source
var ErrUnlocked = errors.New("mutex is unlocked")
View Source
var LogLevelNames = map[LogLevel]string{
	LogLevelDebug:    "DEBUG",
	LogLevelInfo:     "INFO",
	LogLevelWarning:  "WARNING",
	LogLevelError:    "ERROR",
	LogLevelCritical: "CRITICAL",
}

Functions

func ContextWithInterruptCancel

func ContextWithInterruptCancel(log Logger, parent context.Context) (context.Context, error)

Types

type DebugMode

type DebugMode bool

func ProvideDebugMode

func ProvideDebugMode(environ Environ) DebugMode

type Environ

type Environ map[string]string

func ProvideEnvironFromProcessEnvironment

func ProvideEnvironFromProcessEnvironment() (Environ, error)

func (Environ) GetBool

func (environ Environ) GetBool(key string) bool

func (Environ) GetInt

func (environ Environ) GetInt(key string) (int, error)

func (Environ) GetString

func (environ Environ) GetString(key string) (string, error)

type Lock

type Lock chan any

func (*Lock) Acquire

func (m *Lock) Acquire() (func() error, error)

func (Lock) IsLocked

func (m Lock) IsLocked() bool

type LogLevel

type LogLevel int

LogLevel is what it says on the tin Any value other than the debug/info/warning/error/critical will raise an error during configuration

const (
	LogLevelUnknown  LogLevel = 0
	LogLevelDebug    LogLevel = iota
	LogLevelInfo     LogLevel = iota
	LogLevelWarning  LogLevel = iota
	LogLevelError    LogLevel = iota
	LogLevelCritical LogLevel = iota
)

func ParseLogLevel

func ParseLogLevel(text string) (LogLevel, error)

func ProvideLogLevel

func ProvideLogLevel(debugMode DebugMode, environ Environ) LogLevel

func (LogLevel) Name

func (ll LogLevel) Name() string

type LogPrefix

type LogPrefix string

LogPrefix should be injected from elsewhere See LoggingWireSetFactory

type LogWriter

type LogWriter io.Writer

LogWriter should be injected from elsewhere See LoggingWireSetFactory

type Logger

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

func ProvideLogger

func ProvideLogger(writer LogWriter, prefix LogPrefix, debugMode DebugMode, logLevel LogLevel) Logger

func (Logger) Criticalf

func (logger Logger) Criticalf(format string, args ...any)

func (Logger) Debugf

func (logger Logger) Debugf(format string, args ...any)

func (Logger) Errorf

func (logger Logger) Errorf(format string, args ...any)

func (Logger) Infof

func (logger Logger) Infof(format string, args ...any)

func (Logger) Logf

func (logger Logger) Logf(callDepth int, level LogLevel, format string, args ...any)

func (Logger) Warningf

func (logger Logger) Warningf(format string, args ...any)

type WrappedLogger

type WrappedLogger *log.Logger

Jump to

Keyboard shortcuts

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