From e3c379d069ffa9661561d25cdbf2f5894a2f8ee8 Mon Sep 17 00:00:00 2001 From: Adam Mathes Date: Sat, 14 Feb 2026 08:58:38 -0800 Subject: Refactor: project structure, implement dependency injection, and align v2 UI with v1 --- vlog/vlog.go | 25 ------------------ vlog/vlog_test.go | 78 ------------------------------------------------------- 2 files changed, 103 deletions(-) delete mode 100644 vlog/vlog.go delete mode 100644 vlog/vlog_test.go (limited to 'vlog') diff --git a/vlog/vlog.go b/vlog/vlog.go deleted file mode 100644 index ab48478..0000000 --- a/vlog/vlog.go +++ /dev/null @@ -1,25 +0,0 @@ -// vlog -- verbose logger -- wraps log functions and only performs them if "verbose" -package vlog - -import ( - "fmt" -) - -var VERBOSE bool - -func init() { - VERBOSE=false -} - -func Printf(format string, v ...interface{}) { - if VERBOSE { - fmt.Printf(format, v...) - } -} - -func Println(v ...interface{}) { - if VERBOSE { - fmt.Println(v...) - } -} - diff --git a/vlog/vlog_test.go b/vlog/vlog_test.go deleted file mode 100644 index 9def0f0..0000000 --- a/vlog/vlog_test.go +++ /dev/null @@ -1,78 +0,0 @@ -package vlog - -import ( - "bytes" - "fmt" - "os" - "testing" -) - -func captureStdout(f func()) string { - old := os.Stdout - r, w, _ := os.Pipe() - os.Stdout = w - - f() - - w.Close() - os.Stdout = old - - var buf bytes.Buffer - buf.ReadFrom(r) - return buf.String() -} - -func TestPrintfVerbose(t *testing.T) { - VERBOSE = true - defer func() { VERBOSE = false }() - - output := captureStdout(func() { - Printf("hello %s", "world") - }) - expected := fmt.Sprintf("hello %s", "world") - if output != expected { - t.Errorf("expected %q, got %q", expected, output) - } -} - -func TestPrintfSilent(t *testing.T) { - VERBOSE = false - - output := captureStdout(func() { - Printf("hello %s", "world") - }) - if output != "" { - t.Errorf("expected empty output when not verbose, got %q", output) - } -} - -func TestPrintlnVerbose(t *testing.T) { - VERBOSE = true - defer func() { VERBOSE = false }() - - output := captureStdout(func() { - Println("hello", "world") - }) - expected := fmt.Sprintln("hello", "world") - if output != expected { - t.Errorf("expected %q, got %q", expected, output) - } -} - -func TestPrintlnSilent(t *testing.T) { - VERBOSE = false - - output := captureStdout(func() { - Println("hello", "world") - }) - if output != "" { - t.Errorf("expected empty output when not verbose, got %q", output) - } -} - -func TestInit(t *testing.T) { - // init() sets VERBOSE to false - if VERBOSE != false { - t.Error("VERBOSE should default to false") - } -} -- cgit v1.2.3