From c3d2f34f09aa5a8de6d6abefe94f111ddd0c8b76 Mon Sep 17 00:00:00 2001 From: qowevisa Date: Sat, 19 Oct 2024 10:06:14 +0300 Subject: [PATCH] Add using Log from menu in example --- examples/test/main.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/examples/test/main.go b/examples/test/main.go index 760cf71..49130fa 100644 --- a/examples/test/main.go +++ b/examples/test/main.go @@ -2,6 +2,8 @@ package main import ( "fmt" + "log" + "time" "git.qowevisa.me/Qowevisa/tuimenu/simple" ) @@ -9,9 +11,21 @@ import ( func main() { m := simple.CreateMenu( simple.WithCustomTitle("My Custom Title"), + simple.WithUsageOfEscapeCodes(), ) + // Using this function will redirect every log.PrintX func in THIS file + // to m.Log buffer that will Flush everything at the start of next iteration + m.RedirectLogOutputToBufferedLogger() nameName, err := m.AddCommand("0", "NameName", func(m *simple.Menu) error { - fmt.Printf("hello, world\n") + log.Printf("hello, world\n") + time.Sleep(time.Second * 3) + m.Log.Logf("some data = %d\n", 42) + time.Sleep(time.Second * 1) + m.Log.Logf("some data = %d\n", 43) + time.Sleep(time.Second * 1) + m.Log.Logf("some data = %d\n", 44) + log.Printf("asdas") + time.Sleep(time.Second * 1) return nil }) if err != nil {