aboutsummaryrefslogtreecommitdiffstats
path: root/types.go
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--types.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/types.go b/types.go
index 2206eb2..79ef000 100644
--- a/types.go
+++ b/types.go
@@ -2,6 +2,8 @@ package main
import (
"context"
+ "log"
+ "runtime"
"time"
"github.com/jackc/pgx/v5/pgxpool"
@@ -191,3 +193,21 @@ type RSSConfig struct {
Feeds []FeedConfig `json:"feeds"`
Period int `json:"period"`
}
+
+func LogError(err error) {
+ fn, file, line, ok := runtime.Caller(1)
+ if ok {
+ log.Printf("%s: %s-%d >>> %v", runtime.FuncForPC(fn).Name(), file, line, err)
+ } else {
+ log.Print(err)
+ }
+}
+
+func LogErrorFatal(err error) {
+ fn, file, line, ok := runtime.Caller(1)
+ if ok {
+ log.Fatalf("%s: %s-%d >>> %v", runtime.FuncForPC(fn).Name(), file, line, err)
+ } else {
+ log.Fatal(err)
+ }
+}