forked from security/hakurei
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>
This commit is contained in:
@@ -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...)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user