From 12e7658ed5aeb98c4bcebdc48caec21e44927a51 Mon Sep 17 00:00:00 2001 From: Markus Kuuse Date: Wed, 23 Oct 2024 18:21:28 +0300 Subject: [PATCH] actually push debug package --- debug/debug.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 debug/debug.go diff --git a/debug/debug.go b/debug/debug.go new file mode 100644 index 0000000..7e02d50 --- /dev/null +++ b/debug/debug.go @@ -0,0 +1,23 @@ +package debug + +import ( + "log" + "runtime" +) + +var debugMode bool + +func Init(mode bool) { + debugMode = mode +} + +func Debug(ctx string) { + if debugMode { + _, file, line, ok := runtime.Caller(1) + if ok { + log.Printf("DEBUG: %s:%d %s", file, line, ctx) + } else { + log.Printf("DEBUG: %s", ctx) + } + } +} \ No newline at end of file