From ae1a102882103221ef842176dfd8cb1090d5f591 Mon Sep 17 00:00:00 2001 From: Ophestra Umiker Date: Sat, 26 Oct 2024 23:09:32 +0900 Subject: 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 --- internal/fmsg/verbose.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'internal/fmsg/verbose.go') 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...) } } -- cgit v1.3.1