mirror of
https://github.com/Starlio-app/StarlioX
synced 2024-11-22 08:46:22 +03:00
The logger now shows the file where the error was
This commit is contained in:
parent
b34eebddd5
commit
d0496c5fdf
1 changed files with 4 additions and 2 deletions
|
@ -3,6 +3,7 @@ package functions
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -19,7 +20,6 @@ func Logger(text string) {
|
||||||
}
|
}
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
|
|
||||||
//what file name is it
|
|
||||||
_, file, _, ok := runtime.Caller(1)
|
_, file, _, ok := runtime.Caller(1)
|
||||||
if !ok {
|
if !ok {
|
||||||
file = "???"
|
file = "???"
|
||||||
|
@ -30,7 +30,9 @@ func Logger(text string) {
|
||||||
Logger(err.Error())
|
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"))
|
_, err = f.Write([]byte(now.Format("Mon Jan 2 15:04:05 2006") + " | " + text + " [" + file + "] " + "\n"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Add table
Reference in a new issue