diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-03-17 02:55:36 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-03-17 02:55:36 +0900 |
| commit | 24618ab9a1524e8b8986a9bf67667288e642fcf1 (patch) | |
| tree | b3f2a71a2c9bedf937d0fec00092ad9133cb3ec9 /internal/sandbox/msg.go | |
| parent | 9ce4706a0766880c072cccd2643d66f614a6a16b (diff) | |
sandbox: move out of internal
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/sandbox/msg.go')
| -rw-r--r-- | internal/sandbox/msg.go | 43 |
1 files changed, 0 insertions, 43 deletions
diff --git a/internal/sandbox/msg.go b/internal/sandbox/msg.go deleted file mode 100644 index 5ee18509..00000000 --- a/internal/sandbox/msg.go +++ /dev/null @@ -1,43 +0,0 @@ -package sandbox - -import ( - "log" - "sync/atomic" -) - -type Msg interface { - IsVerbose() bool - Verbose(v ...any) - Verbosef(format string, v ...any) - WrapErr(err error, a ...any) error - PrintBaseErr(err error, fallback string) - - Suspend() - Resume() bool - - BeforeExit() -} - -type DefaultMsg struct{ inactive atomic.Bool } - -func (msg *DefaultMsg) IsVerbose() bool { return true } -func (msg *DefaultMsg) Verbose(v ...any) { - if !msg.inactive.Load() { - log.Println(v...) - } -} -func (msg *DefaultMsg) Verbosef(format string, v ...any) { - if !msg.inactive.Load() { - log.Printf(format, v...) - } -} - -func (msg *DefaultMsg) WrapErr(err error, a ...any) error { - log.Println(a...) - return err -} -func (msg *DefaultMsg) PrintBaseErr(err error, fallback string) { log.Println(fallback, err) } - -func (msg *DefaultMsg) Suspend() { msg.inactive.Store(true) } -func (msg *DefaultMsg) Resume() bool { return msg.inactive.CompareAndSwap(true, false) } -func (msg *DefaultMsg) BeforeExit() {} |
