Goit

Simple and lightweight Git web server
git clone http://git.omkov.net/Goit
Log | Tree | Refs | README | Download

Goit/src/util/log.go (31 lines, 443 B) -rw-r--r-- file download

c2c5250 Jakob Wakeling 2023-12-12 09:13:37
0
// Copyright (C) 2023, Jakob Wakeling
c2c5250 Jakob Wakeling 2023-12-12 09:13:37
1
// All rights reserved.
c2c5250 Jakob Wakeling 2023-12-12 09:13:37
2
570144e Jakob Wakeling 2023-12-15 23:28:06
3
package util
5166d87 Jakob Wakeling 2023-10-23 16:00:35
4
a0ac27c Jakob Wakeling 2024-07-06 23:32:05
5
import (
a0ac27c Jakob Wakeling 2024-07-06 23:32:05
6
	"log"
a0ac27c Jakob Wakeling 2024-07-06 23:32:05
7
	"runtime"
a0ac27c Jakob Wakeling 2024-07-06 23:32:05
8
)
5166d87 Jakob Wakeling 2023-10-23 16:00:35
9
5166d87 Jakob Wakeling 2023-10-23 16:00:35
10
var Debug = false
a0ac27c Jakob Wakeling 2024-07-06 23:32:05
11
a0ac27c Jakob Wakeling 2024-07-06 23:32:05
12
func PrintFuncError(err error) {
a0ac27c Jakob Wakeling 2024-07-06 23:32:05
13
	pc, _, _, ok := runtime.Caller(1)
a0ac27c Jakob Wakeling 2024-07-06 23:32:05
14
	if !ok {
a0ac27c Jakob Wakeling 2024-07-06 23:32:05
15
		log.Println(err)
a0ac27c Jakob Wakeling 2024-07-06 23:32:05
16
		return
a0ac27c Jakob Wakeling 2024-07-06 23:32:05
17
	}
a0ac27c Jakob Wakeling 2024-07-06 23:32:05
18
a0ac27c Jakob Wakeling 2024-07-06 23:32:05
19
	fn := runtime.FuncForPC(pc)
a0ac27c Jakob Wakeling 2024-07-06 23:32:05
20
	log.Printf("[%s] %s\n", fn.Name(), err.Error())
a0ac27c Jakob Wakeling 2024-07-06 23:32:05
21
}
5166d87 Jakob Wakeling 2023-10-23 16:00:35
22
5166d87 Jakob Wakeling 2023-10-23 16:00:35
23
func Debugln(v ...any) {
5166d87 Jakob Wakeling 2023-10-23 16:00:35
24
	if Debug {
5166d87 Jakob Wakeling 2023-10-23 16:00:35
25
		var a = []any{"\033[34m[DEBUG]\033[0m"}
5166d87 Jakob Wakeling 2023-10-23 16:00:35
26
		a = append(a, v...)
5166d87 Jakob Wakeling 2023-10-23 16:00:35
27
		log.Println(a...)
5166d87 Jakob Wakeling 2023-10-23 16:00:35
28
	}
5166d87 Jakob Wakeling 2023-10-23 16:00:35
29
}
30