aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-02-18 22:44:50 +0900
committerOphestra <cat@gensokyo.uk>2025-02-18 22:52:09 +0900
commitffaa12b9d8a71a6e9918848bc6d42e010eddfca0 (patch)
treec781aac826f1fa72bcdeae62266964b72b02bfa4
parentbf9512733267e2781cf50070a6606d8f1a8bf5d9 (diff)
sys: wrap log methods
Signed-off-by: Ophestra <cat@gensokyo.uk>
-rw-r--r--internal/app/app_stub_test.go4
-rw-r--r--internal/sys/interface.go3
-rw-r--r--internal/sys/std.go2
3 files changed, 9 insertions, 0 deletions
diff --git a/internal/app/app_stub_test.go b/internal/app/app_stub_test.go
index 1b6d5780..89804d29 100644
--- a/internal/app/app_stub_test.go
+++ b/internal/app/app_stub_test.go
@@ -3,6 +3,7 @@ package app_test
import (
"fmt"
"io/fs"
+ "log"
"os/user"
"strconv"
@@ -23,6 +24,9 @@ func (s *stubNixOS) Exit(code int) { panic("called ex
func (s *stubNixOS) EvalSymlinks(path string) (string, error) { return path, nil }
func (s *stubNixOS) Uid(aid int) (int, error) { return 1000000 + 0*10000 + aid, nil }
+func (s *stubNixOS) Println(v ...any) { log.Println(v...) }
+func (s *stubNixOS) Printf(format string, v ...any) { log.Printf(format, v...) }
+
func (s *stubNixOS) LookupEnv(key string) (string, bool) {
switch key {
case "SHELL":
diff --git a/internal/sys/interface.go b/internal/sys/interface.go
index 80a07ae6..da1cf077 100644
--- a/internal/sys/interface.go
+++ b/internal/sys/interface.go
@@ -34,6 +34,9 @@ type State interface {
// Exit provides [os.Exit].
Exit(code int)
+ Println(v ...any)
+ Printf(format string, v ...any)
+
// Paths returns a populated [Paths] struct.
Paths() Paths
// Uid invokes fsu and returns target uid.
diff --git a/internal/sys/std.go b/internal/sys/std.go
index c7228599..88579f6d 100644
--- a/internal/sys/std.go
+++ b/internal/sys/std.go
@@ -41,6 +41,8 @@ func (s *Std) Stat(name string) (fs.FileInfo, error) { return os.Stat(nam
func (s *Std) Open(name string) (fs.File, error) { return os.Open(name) }
func (s *Std) EvalSymlinks(path string) (string, error) { return filepath.EvalSymlinks(path) }
func (s *Std) Exit(code int) { internal.Exit(code) }
+func (s *Std) Println(v ...any) { fmsg.Verbose(v...) }
+func (s *Std) Printf(format string, v ...any) { fmsg.Verbosef(format, v...) }
const xdgRuntimeDir = "XDG_RUNTIME_DIR"