config

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2023 License: MIT Imports: 7 Imported by: 4

README

Config

Common configuration

Logger

Represents a logger configuration and ability to create a slog logger instance.

type Logger struct {
    Level  string // Logger level
    Format string // logger formatter
}

Monitoring

Represents a monitoring configuration and ability to create a Sentry client and Prometheus handler.

type Monitoring struct {
	SentryDSN string // Sentry DSN
	PromAddr  string // Prometheus address for metrics
}

Utility

  • GetVersion - returns the version of the application (hash commit)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetVersion added in v0.1.1

func GetVersion() string

GetVersion returns latest git hash of commit.

func InitMetrics added in v0.1.1

func InitMetrics(addr string, logger *slog.Logger)

InitMetrics init metrics handler for Prometheus.

func InitSentry added in v0.1.1

func InitSentry(dsn, ver string) error

InitSentry init Sentry client.

func InitSlog

func InitSlog(cfg *Logger, version string, hook bool) *slog.Logger

InitSlog init slog logger instance with version field and hook for Sentry.

Types

type Logger

type Logger struct {
	Level LoggerLevel `yaml:"level" env:"LEVEL,required" valid:"required"`
	Fmt   string      `yaml:"fmt" env:"FMT,default=json"`
}

Logger represent configuration for any logger.

type LoggerLevel

type LoggerLevel string

LoggerLevel log levels.

const (
	LoggerLevelDebug LoggerLevel = "debug"
	LoggerLevelInfo  LoggerLevel = "info"
	LoggerLevelWarn  LoggerLevel = "warn"
	LoggerLevelError LoggerLevel = "error"
)

type Monitoring added in v0.1.1

type Monitoring struct {
	SentryDSN string `yaml:"sentry_dsn" env:"SENTRY_DSN"`
	PromAddr  string `yaml:"prom_addr" env:"PROM_ADDR"`
}

Monitoring represent configuration for any monitoring.

Jump to

Keyboard shortcuts

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