Refactor the code to use more modular and testable approach.

This commit is contained in:
2025-02-25 19:11:19 +00:00
parent 5964da3cef
commit 942e648d56
18 changed files with 1719 additions and 595 deletions
+59
View File
@@ -0,0 +1,59 @@
package utils
import (
"os"
libpack_logging "github.com/lukaszraczylo/graphql-monitoring-proxy/logging"
)
// Logger is a global logger instance
var Logger *libpack_logging.Logger
// InitLogger initializes the logger with the specified debug level
func InitLogger(debug bool) *libpack_logging.Logger {
Logger = libpack_logging.New()
if debug {
Logger.SetOutput(os.Stdout).SetMinLogLevel(libpack_logging.LEVEL_DEBUG)
}
return Logger
}
// Debug logs a debug message
func Debug(message string, pairs map[string]interface{}) {
if Logger != nil {
Logger.Debug(&libpack_logging.LogMessage{
Message: message,
Pairs: pairs,
})
}
}
// Info logs an info message
func Info(message string, pairs map[string]interface{}) {
if Logger != nil {
Logger.Info(&libpack_logging.LogMessage{
Message: message,
Pairs: pairs,
})
}
}
// Error logs an error message
func Error(message string, pairs map[string]interface{}) {
if Logger != nil {
Logger.Error(&libpack_logging.LogMessage{
Message: message,
Pairs: pairs,
})
}
}
// Critical logs a critical message
func Critical(message string, pairs map[string]interface{}) {
if Logger != nil {
Logger.Critical(&libpack_logging.LogMessage{
Message: message,
Pairs: pairs,
})
}
}