From 42e0b168e3d75389dfb968aebf9f5629d64782f9 Mon Sep 17 00:00:00 2001 From: Ophestra Umiker Date: Mon, 21 Oct 2024 20:47:02 +0900 Subject: fmsg: produce all output through fmsg The behaviour of print functions from package fmt is not thread safe. Functions provided by fmsg wrap around Logger methods. This makes prefix much cleaner and makes it easy to deal with future changes to logging. Signed-off-by: Ophestra Umiker --- config.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'config.go') diff --git a/config.go b/config.go index 228d3feb..26510e40 100644 --- a/config.go +++ b/config.go @@ -9,6 +9,7 @@ import ( "git.ophivana.moe/security/fortify/dbus" "git.ophivana.moe/security/fortify/internal" "git.ophivana.moe/security/fortify/internal/app" + "git.ophivana.moe/security/fortify/internal/fmsg" "git.ophivana.moe/security/fortify/internal/system" ) @@ -60,7 +61,7 @@ func init() { func tryTemplate() { if printTemplate { if s, err := json.MarshalIndent(app.Template(), "", " "); err != nil { - fatalf("cannot generate template: %v", err) + fmsg.Fatalf("cannot generate template: %v", err) panic("unreachable") } else { fmt.Println(string(s)) @@ -77,10 +78,10 @@ func loadConfig() *app.Config { // config from file c := new(app.Config) if f, err := os.Open(confPath); err != nil { - fatalf("cannot access config file '%s': %s\n", confPath, err) + fmsg.Fatalf("cannot access config file %q: %s", confPath, err) panic("unreachable") } else if err = json.NewDecoder(f).Decode(&c); err != nil { - fatalf("cannot parse config file '%s': %s\n", confPath, err) + fmsg.Fatalf("cannot parse config file %q: %s", confPath, err) panic("unreachable") } else { return c @@ -110,7 +111,7 @@ func configFromFlags() (config *app.Config) { config.Confinement.SessionBus = dbus.NewConfig(dbusID, true, mpris) } else { if c, err := dbus.NewConfigFromFile(dbusConfigSession); err != nil { - fatalf("cannot load session bus proxy config from %q: %s\n", dbusConfigSession, err) + fmsg.Fatalf("cannot load session bus proxy config from %q: %s", dbusConfigSession, err) } else { config.Confinement.SessionBus = c } @@ -119,7 +120,7 @@ func configFromFlags() (config *app.Config) { // system bus proxy is optional if dbusConfigSystem != "nil" { if c, err := dbus.NewConfigFromFile(dbusConfigSystem); err != nil { - fatalf("cannot load system bus proxy config from %q: %s\n", dbusConfigSystem, err) + fmsg.Fatalf("cannot load system bus proxy config from %q: %s", dbusConfigSystem, err) } else { config.Confinement.SystemBus = c } -- cgit v1.3.1