From d0496c5fdffce3d20ad8b6217ae474c32ae9d73a Mon Sep 17 00:00:00 2001 From: Redume Date: Sun, 2 Oct 2022 12:18:29 +0300 Subject: [PATCH] The logger now shows the file where the error was --- functions/logger.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/functions/logger.go b/functions/logger.go index e2281a8..eb5189b 100644 --- a/functions/logger.go +++ b/functions/logger.go @@ -3,6 +3,7 @@ package functions import ( "os" "runtime" + "strings" "time" ) @@ -19,7 +20,6 @@ func Logger(text string) { } now := time.Now() - //what file name is it _, file, _, ok := runtime.Caller(1) if !ok { file = "???" @@ -30,7 +30,9 @@ func Logger(text string) { Logger(err.Error()) } - file = file[len(dir)+1:] + if strings.Contains(file, dir) { + file = file[len(dir)+1:] + } _, err = f.Write([]byte(now.Format("Mon Jan 2 15:04:05 2006") + " | " + text + " [" + file + "] " + "\n")) if err != nil {