aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/app/start.go
diff options
context:
space:
mode:
authorOphestra Umiker <cat@ophivana.moe>2024-10-21 20:47:02 +0900
committerOphestra Umiker <cat@ophivana.moe>2024-10-21 20:47:02 +0900
commit42e0b168e3d75389dfb968aebf9f5629d64782f9 (patch)
treee6b430205213c62bc06275c6d84e6037d40f5c3f /internal/app/start.go
parent380d1f45851b7dffb963c51da96a17ba41f3cfb8 (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 'internal/app/start.go')
-rw-r--r--internal/app/start.go18
1 files changed, 8 insertions, 10 deletions
diff --git a/internal/app/start.go b/internal/app/start.go
index 3106a1e8..b6c94041 100644
--- a/internal/app/start.go
+++ b/internal/app/start.go
@@ -7,7 +7,6 @@ import (
"os/exec"
"path"
"path/filepath"
- "strconv"
"strings"
"time"
@@ -16,7 +15,6 @@ import (
"git.ophivana.moe/security/fortify/internal/shim"
"git.ophivana.moe/security/fortify/internal/state"
"git.ophivana.moe/security/fortify/internal/system"
- "git.ophivana.moe/security/fortify/internal/verbose"
)
// Start starts the fortified child
@@ -71,14 +69,14 @@ func (a *app) Start() error {
Bwrap: a.seal.sys.bwrap,
WL: a.seal.wl != nil,
- Verbose: verbose.Get(),
+ Verbose: fmsg.Verbose(),
}, a.seal.wl); err != nil {
return fmsg.WrapErrorSuffix(err,
"cannot serve shim setup:")
}
// start shim
- verbose.Println("starting shim as target user:", a.cmd)
+ fmsg.VPrintln("starting shim as target user:", a.cmd)
if err := a.cmd.Start(); err != nil {
return fmsg.WrapErrorSuffix(err,
"cannot start process:")
@@ -178,12 +176,12 @@ func (a *app) Wait() (int, error) {
r = a.cmd.ProcessState.ExitCode()
}
- verbose.Println("process", strconv.Itoa(a.cmd.Process.Pid), "exited with exit code", r)
+ fmsg.VPrintf("process %d exited with exit code %d", a.cmd.Process.Pid, r)
// close wayland connection
if a.seal.wl != nil {
if err := a.seal.wl.Close(); err != nil {
- fmt.Println("fortify: cannot close wayland connection:", err)
+ fmsg.Println("cannot close wayland connection:", err)
}
}
@@ -205,10 +203,10 @@ func (a *app) Wait() (int, error) {
} else {
if l := len(states); l == 0 {
// cleanup globals as the final launcher
- verbose.Println("no other launchers active, will clean up globals")
+ fmsg.VPrintln("no other launchers active, will clean up globals")
ec.Set(system.User)
} else {
- verbose.Printf("found %d active launchers, cleaning up without globals\n", l)
+ fmsg.VPrintf("found %d active launchers, cleaning up without globals", l)
}
// accumulate capabilities of other launchers
@@ -222,7 +220,7 @@ func (a *app) Wait() (int, error) {
ec.Set(i)
}
}
- if verbose.Get() {
+ if fmsg.Verbose() {
labels := make([]string, 0, system.ELen+1)
for i := system.Enablement(0); i < system.Enablement(system.ELen+2); i++ {
if ec.Has(i) {
@@ -230,7 +228,7 @@ func (a *app) Wait() (int, error) {
}
}
if len(labels) > 0 {
- verbose.Println("reverting operations labelled", strings.Join(labels, ", "))
+ fmsg.VPrintln("reverting operations labelled", strings.Join(labels, ", "))
}
}