common

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplySectionAndProfile

func ApplySectionAndProfile(v *viper.Viper, section, profile string) (*viper.Viper, error)

ApplySectionAndProfile extracts a section (server/agent/edge) and overlays profiles.<name> if present.

func GetLogCounters

func GetLogCounters() map[string]int64

GetLogCounters returns current log counters by level.

func LoadWithIncludes

func LoadWithIncludes(base string, includes []string) (*viper.Viper, error)

LoadWithIncludes reads base config and merges includes in order.

func MergeLogSection

func MergeLogSection(v *viper.Viper)

MergeLogSection flattens a nested "log" section into top-level log.* keys.

func SetupLoggerWithFile

func SetupLoggerWithFile(level, format, filePath string, maxSizeMB, maxBackups, maxAgeDays int, compress bool)

SetupLoggerWithFile configures both std log and slog default logger. format: console|json; level: debug|info|warn|error. If filePath != "", logs write to a rotating file.

func ValidateAddr

func ValidateAddr(addr string) error

func ValidateAgentConfig

func ValidateAgentConfig(v *viper.Viper, strict bool) error

func ValidateServerConfig

func ValidateServerConfig(v *viper.Viper, strict bool) error

func ValidateTLS

func ValidateTLS(cert, key, ca string, strict bool) error

Types

type LogConfig added in v0.1.4

type LogConfig struct {
	Level      string `json:",omitempty" yaml:",omitempty"` // debug|info|warn|error
	Format     string `json:",omitempty" yaml:",omitempty"` // console|json
	Output     string `json:",omitempty" yaml:",omitempty"` // stdout|stderr
	File       string `json:",omitempty" yaml:",omitempty"` // 日志文件路径
	MaxSize    int    `json:",omitempty" yaml:",omitempty"` // 单个日志文件最大大小(MB)
	MaxBackups int    `json:",omitempty" yaml:",omitempty"` // 保留的旧日志文件最大数量
	MaxAge     int    `json:",omitempty" yaml:",omitempty"` // 保留旧日志文件的最大天数
	Compress   bool   `json:",omitempty" yaml:",omitempty"` // 是否压缩旧日志文件
}

LogConfig 日志配置(通用结构,供所有服务使用)

Jump to

Keyboard shortcuts

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