redefine logging Config to Cfg

This commit is contained in:
Helmut Merz 2023-06-24 10:37:24 +02:00
parent 72abf7cc0f
commit 2712f3cb38
4 changed files with 8 additions and 6 deletions

View file

@ -17,7 +17,7 @@ type Cfg struct {
*config.BaseCfg *config.BaseCfg
AppType string AppType string
Home string Home string
Logging *logging.Config Logging *logging.Cfg
} }
func Start(ctx lib.Context) { func Start(ctx lib.Context) {

View file

@ -14,7 +14,7 @@ func Config() lib.Config {
BaseCfg: b("dummy", app.Start), BaseCfg: b("dummy", app.Start),
Home: ovr(".", HOME), Home: ovr(".", HOME),
AppType: "standard", AppType: "standard",
Logging: &logging.Config{ Logging: &logging.Cfg{
Logfile: ovr("log/scopes.log", LOGFILE), Logfile: ovr("log/scopes.log", LOGFILE),
}, },
} }

View file

@ -4,6 +4,7 @@ import (
"fmt" "fmt"
"path/filepath" "path/filepath"
"git.sr.ht/~cco/go-scopes/config"
"git.sr.ht/~cco/go-scopes/lib" "git.sr.ht/~cco/go-scopes/lib"
"github.com/rs/zerolog" "github.com/rs/zerolog"
"github.com/rs/zerolog/log" "github.com/rs/zerolog/log"
@ -13,12 +14,13 @@ type Logger = zerolog.Logger
var globalLogger Logger = log.Logger var globalLogger Logger = log.Logger
type Config struct { type Cfg struct {
*config.BaseCfg
Logfile string Logfile string
Level zerolog.Level Level zerolog.Level
} }
func Setup(ctx lib.Context, cfg *Config, home string) { func Setup(ctx lib.Context, cfg *Cfg, home string) {
if cfg == nil { if cfg == nil {
return // use unchanged predefined logger return // use unchanged predefined logger
} }
@ -32,7 +34,7 @@ func Setup(ctx lib.Context, cfg *Config, home string) {
fmt.Println("logfile:", fn) fmt.Println("logfile:", fn)
} }
func New(cfg *Config, home string) *Logger { func New(cfg *Cfg, home string) *Logger {
return nil return nil
} }

View file

@ -18,7 +18,7 @@ func Config() lib.Config {
BaseCfg: b("testing", testing.Start), BaseCfg: b("testing", testing.Start),
Home: ovr(".", HOME), Home: ovr(".", HOME),
AppType: "standard", AppType: "standard",
Logging: &logging.Config{ Logging: &logging.Cfg{
Logfile: ovr("log/scopes.log", LOGFILE), Logfile: ovr("log/scopes.log", LOGFILE),
}, },
} }