config

package
v1.15.0 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2026 License: GPL-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultLogWriter added in v1.1.0

func DefaultLogWriter(version string) io.Writer

DefaultLogWriter returns the base log writer for the provided version.

func GetDefaultConfigDir added in v0.3.0

func GetDefaultConfigDir() string

GetDefaultConfigDir returns the OS-specific config directory

func InitDefaultLogger added in v1.1.0

func InitDefaultLogger(version string)

InitDefaultLogger configures zerolog with the default writer for this version. This is used by CLI entry points before a configuration file is loaded.

func WriteDefaultConfig added in v0.3.0

func WriteDefaultConfig(path string) error

Types

type AppConfig

type AppConfig struct {
	Config *domain.Config
	// contains filtered or unexported fields
}

func New

func New(configDirOrPath string, versions ...string) (*AppConfig, error)

func (*AppConfig) ApplyLogConfig

func (c *AppConfig) ApplyLogConfig() error

func (*AppConfig) GetConfigDir added in v1.3.0

func (c *AppConfig) GetConfigDir() string

GetConfigDir returns the directory containing the config file

func (*AppConfig) GetDataDir

func (c *AppConfig) GetDataDir() string

GetDataDir returns the resolved data directory path.

func (*AppConfig) GetDatabasePath

func (c *AppConfig) GetDatabasePath() string

GetDatabasePath returns the path to the database file

func (*AppConfig) GetEncryptionKey

func (c *AppConfig) GetEncryptionKey() []byte

GetEncryptionKey derives a 32-byte encryption key from the session secret

func (*AppConfig) GetLockedLogSettings added in v1.12.0

func (c *AppConfig) GetLockedLogSettings() map[string]string

GetLockedLogSettings returns a map of log setting keys that are locked by env/CLI.

func (*AppConfig) GetLogManager added in v1.12.0

func (c *AppConfig) GetLogManager() *LogManager

GetLogManager returns the LogManager for log streaming.

func (*AppConfig) GetLogSettings added in v1.12.0

func (c *AppConfig) GetLogSettings() LogSettingsResponse

GetLogSettings returns the current log settings with locked field information. The Path field is resolved to an absolute path (relative paths are resolved against the config directory).

func (*AppConfig) PersistLogSettings added in v1.12.0

func (c *AppConfig) PersistLogSettings(level, path string, maxSize, maxBackups int) error

PersistLogSettings atomically updates only the log-related keys in config.toml. It preserves all other content and comments.

func (*AppConfig) RegisterReloadListener added in v1.0.0

func (c *AppConfig) RegisterReloadListener(fn func(*domain.Config))

RegisterReloadListener registers a callback that's invoked when the configuration file is reloaded.

func (*AppConfig) ResolveLogPath added in v1.12.0

func (c *AppConfig) ResolveLogPath(logPath string) string

ResolveLogPath resolves a log path, making relative paths relative to the config directory. Returns empty string if logPath is empty (stdout only).

func (*AppConfig) SetDataDir

func (c *AppConfig) SetDataDir(dir string)

SetDataDir sets the data directory (used by CLI flags)

func (*AppConfig) UpdateLogSettings added in v1.12.0

func (c *AppConfig) UpdateLogSettings(update LogSettingsUpdate) (LogSettingsResponse, error)

UpdateLogSettings validates and applies log settings updates. It rejects changes to locked fields and returns an error if any locked field is modified.

type LogManager added in v1.12.0

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

LogManager handles log configuration with safe runtime reconfiguration.

func NewLogManager added in v1.12.0

func NewLogManager(version string) *LogManager

NewLogManager creates a new LogManager with the given version string.

func (*LogManager) Apply added in v1.12.0

func (lm *LogManager) Apply(level, logPath string, maxSize, maxBackups int) error

Apply updates the log configuration with the given settings. It is safe to call this method concurrently from multiple goroutines. Returns an error if file logging is requested but cannot be enabled.

func (*LogManager) GetHub added in v1.12.0

func (lm *LogManager) GetHub() *logstream.Hub

GetHub returns the log streaming hub for SSE endpoints.

func (*LogManager) Initialize added in v1.12.0

func (lm *LogManager) Initialize()

Initialize sets up the global logger to use the switchable writer. This should only be called once during application startup.

type LogSettingsResponse added in v1.12.0

type LogSettingsResponse struct {
	Level      string            `json:"level"`
	Path       string            `json:"path"`
	MaxSize    int               `json:"maxSize"`
	MaxBackups int               `json:"maxBackups"`
	ConfigPath string            `json:"configPath,omitempty"`
	Locked     map[string]string `json:"locked,omitempty"`
}

LogSettingsResponse represents the log settings for API responses.

type LogSettingsUpdate added in v1.12.0

type LogSettingsUpdate struct {
	Level      *string `json:"level,omitempty"`
	Path       *string `json:"path,omitempty"`
	MaxSize    *int    `json:"maxSize,omitempty"`
	MaxBackups *int    `json:"maxBackups,omitempty"`
}

LogSettingsUpdate represents a request to update log settings.

Jump to

Keyboard shortcuts

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