aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/fmsg/verbose.go
diff options
context:
space:
mode:
authorOphestra Umiker <cat@ophivana.moe>2024-10-21 20:47:02 +0900
committerOphestra Umiker <cat@ophivana.moe>2024-10-21 20:47:02 +0900
commit42e0b168e3d75389dfb968aebf9f5629d64782f9 (patch)
treee6b430205213c62bc06275c6d84e6037d40f5c3f /internal/fmsg/verbose.go
parent380d1f45851b7dffb963c51da96a17ba41f3cfb8 (diff)
fmsg: produce all output through fmsg
The behaviour of print functions from package fmt is not thread safe. Functions provided by fmsg wrap around Logger methods. This makes prefix much cleaner and makes it easy to deal with future changes to logging. Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
Diffstat (limited to 'internal/fmsg/verbose.go')
-rw-r--r--internal/fmsg/verbose.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/internal/fmsg/verbose.go b/internal/fmsg/verbose.go
new file mode 100644
index 00000000..36faadeb
--- /dev/null
+++ b/internal/fmsg/verbose.go
@@ -0,0 +1,21 @@
+package fmsg
+
+func Verbose() bool {
+ return verbose.Load()
+}
+
+func SetVerbose(v bool) {
+ verbose.Store(v)
+}
+
+func VPrintf(format string, v ...any) {
+ if verbose.Load() {
+ std.Printf(format, v...)
+ }
+}
+
+func VPrintln(v ...any) {
+ if verbose.Load() {
+ std.Println(v...)
+ }
+}