e1.3.0 Config dependency update.
This commit is contained in:
@ -5,7 +5,7 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Config holds all logger configuration values, populated via config.UnmarshalSubtree
|
||||
// Config holds all logger configuration values
|
||||
type Config struct {
|
||||
// Basic settings
|
||||
Level int64 `toml:"level"`
|
||||
@ -42,7 +42,7 @@ type Config struct {
|
||||
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{
|
||||
// Basic settings
|
||||
Level: LevelInfo,
|
||||
|
||||
4
go.mod
4
go.mod
@ -2,9 +2,9 @@ module github.com/LixenWraith/log
|
||||
|
||||
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 (
|
||||
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
|
||||
)
|
||||
|
||||
8
go.sum
8
go.sum
@ -1,6 +1,6 @@
|
||||
github.com/LixenWraith/config v0.0.0-20250423082047-b106c94c2c8b h1:IYhbozsDOhT1fiogABpomRq9IEonNmQs54ROPn3Xy4g=
|
||||
github.com/LixenWraith/config v0.0.0-20250423082047-b106c94c2c8b/go.mod h1:LWz2FXeYAN1IxmPFAmbMZLhL/5LbHzJgnj4m7l5jGvc=
|
||||
github.com/LixenWraith/tinytoml v0.0.0-20250422065624-8aa28720f04a h1:m+lhpIexwlJa5m1QuEveRmaGIE+wp87T97PyX1IWbMw=
|
||||
github.com/LixenWraith/tinytoml v0.0.0-20250422065624-8aa28720f04a/go.mod h1:Vax79K0I//Klsa8POjua/XHbsMUiIdjJHr59VFbc0/8=
|
||||
github.com/BurntSushi/toml v1.5.0 h1:W5quZX/G/csjUnuI8SUYlsHs9M38FC7znL0lIO+DvMg=
|
||||
github.com/BurntSushi/toml v1.5.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
|
||||
github.com/LixenWraith/config v0.0.0-20250426061518-532233ac282c h1:3JcYZVGF+OOfm72eOE2LLFHU9ERYSKs76jJOxpB/4FQ=
|
||||
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/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||
|
||||
10
logger.go
10
logger.go
@ -2,6 +2,7 @@
|
||||
package log
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
@ -58,8 +59,13 @@ func NewLogger() *Logger {
|
||||
|
||||
// LoadConfig loads logger configuration from a file with optional CLI overrides
|
||||
func (l *Logger) LoadConfig(path string, args []string) error {
|
||||
configExists, err := l.config.Load(path, args)
|
||||
if err != nil {
|
||||
err := l.config.Load(path, args)
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user