diff options
| author | Ophestra Umiker <cat@ophivana.moe> | 2024-10-21 20:47:02 +0900 |
|---|---|---|
| committer | Ophestra Umiker <cat@ophivana.moe> | 2024-10-21 20:47:02 +0900 |
| commit | 42e0b168e3d75389dfb968aebf9f5629d64782f9 (patch) | |
| tree | e6b430205213c62bc06275c6d84e6037d40f5c3f /main.go | |
| parent | 380d1f45851b7dffb963c51da96a17ba41f3cfb8 (diff) | |
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 <cat@ophivana.moe>
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 15 |
1 files changed, 7 insertions, 8 deletions
@@ -2,15 +2,14 @@ package main import ( "flag" - "fmt" "os" "syscall" "git.ophivana.moe/security/fortify/internal" "git.ophivana.moe/security/fortify/internal/app" + "git.ophivana.moe/security/fortify/internal/fmsg" init0 "git.ophivana.moe/security/fortify/internal/init" "git.ophivana.moe/security/fortify/internal/shim" - "git.ophivana.moe/security/fortify/internal/verbose" ) var ( @@ -24,14 +23,14 @@ func init() { func main() { // linux/sched/coredump.h if _, _, errno := syscall.RawSyscall(syscall.SYS_PRCTL, syscall.PR_SET_DUMPABLE, 0, 0); errno != 0 { - fmt.Printf("fortify: cannot set SUID_DUMP_DISABLE: %s", errno.Error()) + fmsg.Printf("fortify: cannot set SUID_DUMP_DISABLE: %s", errno.Error()) } flag.Parse() - verbose.Set(flagVerbose) + fmsg.SetVerbose(flagVerbose) if internal.SdBootedV { - verbose.Println("system booted with systemd as init system") + fmsg.VPrintln("system booted with systemd as init system") } // shim/init early exit @@ -40,7 +39,7 @@ func main() { // root check if os.Getuid() == 0 { - fmt.Println("fortify: this program must not run as root") + fmsg.Println("this program must not run as root") os.Exit(1) } @@ -56,7 +55,7 @@ func main() { r := 1 a, err := app.New() if err != nil { - fatalf("cannot create app: %s\n", err) + fmsg.Fatalf("cannot create app: %s\n", err) } else if err = a.Seal(loadConfig()); err != nil { logBaseError(err, "fortify: cannot seal app:") } else if err = a.Start(); err != nil { @@ -68,7 +67,7 @@ func main() { logWaitError(err) } if err = a.WaitErr(); err != nil { - fmt.Println("fortify: inner wait failed:", err) + fmsg.Println("inner wait failed:", err) } os.Exit(r) } |
