mirror of
https://github.com/mjl-/mox.git
synced 2025-07-10 10:34:40 +03:00
switch to slog.Logger for logging, for easier reuse of packages by external software
we don't want external software to include internal details like mlog. slog.Logger is/will be the standard. we still have mlog for its helper functions, and its handler that logs in concise logfmt used by mox. packages that are not meant for reuse still pass around mlog.Log for convenience. we use golang.org/x/exp/slog because we also support the previous Go toolchain version. with the next Go release, we'll switch to the builtin slog.
This commit is contained in:
@ -8,7 +8,7 @@ import (
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
"github.com/mjl-/mox/mlog"
|
||||
"golang.org/x/exp/slog"
|
||||
)
|
||||
|
||||
// Fork and exec as unprivileged user.
|
||||
@ -19,7 +19,7 @@ import (
|
||||
func ForkExecUnprivileged() {
|
||||
prog, err := os.Executable()
|
||||
if err != nil {
|
||||
xlog.Fatalx("finding executable for exec", err)
|
||||
pkglog.Fatalx("finding executable for exec", err)
|
||||
}
|
||||
|
||||
files := []*os.File{os.Stdin, os.Stdout, os.Stderr}
|
||||
@ -49,7 +49,7 @@ func ForkExecUnprivileged() {
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
xlog.Fatalx("fork and exec", err)
|
||||
pkglog.Fatalx("fork and exec", err)
|
||||
}
|
||||
CleanupPassedFiles()
|
||||
|
||||
@ -66,9 +66,9 @@ func ForkExecUnprivileged() {
|
||||
|
||||
st, err := p.Wait()
|
||||
if err != nil {
|
||||
xlog.Fatalx("wait", err)
|
||||
pkglog.Fatalx("wait", err)
|
||||
}
|
||||
code := st.ExitCode()
|
||||
xlog.Print("stopping after child exit", mlog.Field("exitcode", code))
|
||||
pkglog.Print("stopping after child exit", slog.Int("exitcode", code))
|
||||
os.Exit(code)
|
||||
}
|
||||
|
Reference in New Issue
Block a user