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: "mefit_error_total", Help: "The total number of errors during processing", }, ) ) func Fatal(message string, args ...interface{}) { s := format(message, args) log.Fatal(s) errorMetric.Inc() } func Error(message string, args ...interface{}) { s := format(message, args) slog.Error(s) errorMetric.Inc() } 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() }