summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHandingkang <[email protected]>2023-08-25 14:15:08 +0800
committerHandingkang <[email protected]>2023-08-25 14:15:08 +0800
commit6692efd457196f6459cb3b48bfb6a7f8fdabcb2c (patch)
tree1b15da01ac4ede84c6a009b2d8f5867cf2812cad
parent34d20a8378cd7f454142e76c06952cf457b56be9 (diff)
备用,定义了RunFuncName函数,用于返回当前函数位置以及行号,可用作报错输出信息
-rw-r--r--plugin/pkg/log/runtime.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/plugin/pkg/log/runtime.go b/plugin/pkg/log/runtime.go
new file mode 100644
index 0000000..de54d17
--- /dev/null
+++ b/plugin/pkg/log/runtime.go
@@ -0,0 +1,12 @@
+package log
+
+import "runtime"
+
+// 获取运行时函数
+func RunFuncName() (string, int) {
+ _, file, line, ok := runtime.Caller(1)
+ if ok {
+ return file, line
+ }
+ return "null", 0
+}