e1.3.0 Config dependency update.

This commit is contained in:
2025-04-27 20:57:18 -04:00
parent 764caeb894
commit 7ce7158841
4 changed files with 16 additions and 10 deletions

View File

@ -5,7 +5,7 @@ import (
"strings" "strings"
) )
// Config holds all logger configuration values, populated via config.UnmarshalSubtree // Config holds all logger configuration values
type Config struct { type Config struct {
// Basic settings // Basic settings
Level int64 `toml:"level"` Level int64 `toml:"level"`
@ -42,7 +42,7 @@ type Config struct {
HeartbeatIntervalS int64 `toml:"heartbeat_interval_s"` // Interval seconds for heartbeat HeartbeatIntervalS int64 `toml:"heartbeat_interval_s"` // Interval seconds for heartbeat
} }
// defaultConfig is the single source of truth for all default values // defaultConfig is the single source for all configurable default values
var defaultConfig = Config{ var defaultConfig = Config{
// Basic settings // Basic settings
Level: LevelInfo, Level: LevelInfo,

4
go.mod
View File

@ -2,9 +2,9 @@ module github.com/LixenWraith/log
go 1.24.2 go 1.24.2
require github.com/LixenWraith/config v0.0.0-20250423082047-b106c94c2c8b require github.com/LixenWraith/config v0.0.0-20250426061518-532233ac282c
require ( require (
github.com/LixenWraith/tinytoml v0.0.0-20250422065624-8aa28720f04a // indirect github.com/BurntSushi/toml v1.5.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect
) )

8
go.sum
View File

@ -1,6 +1,6 @@
github.com/LixenWraith/config v0.0.0-20250423082047-b106c94c2c8b h1:IYhbozsDOhT1fiogABpomRq9IEonNmQs54ROPn3Xy4g= github.com/BurntSushi/toml v1.5.0 h1:W5quZX/G/csjUnuI8SUYlsHs9M38FC7znL0lIO+DvMg=
github.com/LixenWraith/config v0.0.0-20250423082047-b106c94c2c8b/go.mod h1:LWz2FXeYAN1IxmPFAmbMZLhL/5LbHzJgnj4m7l5jGvc= github.com/BurntSushi/toml v1.5.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
github.com/LixenWraith/tinytoml v0.0.0-20250422065624-8aa28720f04a h1:m+lhpIexwlJa5m1QuEveRmaGIE+wp87T97PyX1IWbMw= github.com/LixenWraith/config v0.0.0-20250426061518-532233ac282c h1:3JcYZVGF+OOfm72eOE2LLFHU9ERYSKs76jJOxpB/4FQ=
github.com/LixenWraith/tinytoml v0.0.0-20250422065624-8aa28720f04a/go.mod h1:Vax79K0I//Klsa8POjua/XHbsMUiIdjJHr59VFbc0/8= github.com/LixenWraith/config v0.0.0-20250426061518-532233ac282c/go.mod h1:3cBfqRthYrMGIkea2GXyMVPNxVWSYt2FkeWG1Zyv2Ow=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=

View File

@ -2,6 +2,7 @@
package log package log
import ( import (
"errors"
"fmt" "fmt"
"os" "os"
"strings" "strings"
@ -58,8 +59,13 @@ func NewLogger() *Logger {
// LoadConfig loads logger configuration from a file with optional CLI overrides // LoadConfig loads logger configuration from a file with optional CLI overrides
func (l *Logger) LoadConfig(path string, args []string) error { func (l *Logger) LoadConfig(path string, args []string) error {
configExists, err := l.config.Load(path, args) err := l.config.Load(path, args)
if err != nil {
// Check if the error indicates that the file was not found
configExists := !errors.Is(err, config.ErrConfigNotFound)
// If there's an error other than "file not found", return it
if err != nil && !errors.Is(err, config.ErrConfigNotFound) {
return err return err
} }