fix: move implementation to "internal" package
All checks were successful
Build Docker Image / Build-Docker-Image (push) Successful in 4m49s
Build and Push Docker Image / Build-And-Push-Docker-Image (push) Successful in 5m8s

This commit was merged in pull request #138.
This commit is contained in:
2025-05-29 13:23:13 +02:00
parent 9bb0cc475d
commit 6219741634
72 changed files with 245 additions and 230 deletions

56
internal/log/default.go Normal file
View File

@@ -0,0 +1,56 @@
package log
import (
"fmt"
"log"
"log/slog"
"strings"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
)
var (
errorMetric = promauto.NewCounter(
prometheus.CounterOpts{
Name: "spendsparrow_error_total",
Help: "The total number of errors during processing",
},
)
)
func Fatal(message string, args ...interface{}) {
errorMetric.Inc()
s := format(message, args)
log.Fatal(s)
}
func Error(message string, args ...interface{}) {
errorMetric.Inc()
s := format(message, args)
slog.Error(s)
}
func Warn(message string, args ...interface{}) {
s := format(message, args)
slog.Warn(s)
}
func Info(message string, args ...interface{}) {
s := format(message, args)
slog.Info(s)
}
func format(message string, args []interface{}) string {
var w strings.Builder
if len(args) > 0 {
fmt.Fprintf(&w, message, args...)
} else {
w.WriteString(message)
}
return w.String()
}