diff options
| author | Ophestra Umiker <cat@ophivana.moe> | 2024-10-26 23:09:32 +0900 |
|---|---|---|
| committer | Ophestra Umiker <cat@ophivana.moe> | 2024-10-26 23:09:32 +0900 |
| commit | ae1a102882103221ef842176dfd8cb1090d5f591 (patch) | |
| tree | 16f34686bac5564998a9a0e84be96d83ed3e59bd /internal/fmsg/verbose.go | |
| parent | 093e99d062f873dc9d83b1f76a156c1ee4275c57 (diff) | |
fmsg: support temporarily withholding output
Trying to print to a shared stdout is a terrible idea. This change makes it possible to withhold output for the lifetime of the sandbox.
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
Diffstat (limited to 'internal/fmsg/verbose.go')
| -rw-r--r-- | internal/fmsg/verbose.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/internal/fmsg/verbose.go b/internal/fmsg/verbose.go index 36faadeb..72a92a69 100644 --- a/internal/fmsg/verbose.go +++ b/internal/fmsg/verbose.go @@ -1,5 +1,9 @@ package fmsg +import "sync/atomic" + +var verbose = new(atomic.Bool) + func Verbose() bool { return verbose.Load() } @@ -10,12 +14,12 @@ func SetVerbose(v bool) { func VPrintf(format string, v ...any) { if verbose.Load() { - std.Printf(format, v...) + Printf(format, v...) } } func VPrintln(v ...any) { if verbose.Load() { - std.Println(v...) + Println(v...) } } |
