Refactored logging to use custom logger and set default logger.

This commit is contained in:
Jeffrey Paul 2024-05-14 04:46:27 -07:00
parent 24c6ebe407
commit f8bd3147a4
2 changed files with 6 additions and 9 deletions

View File

@ -2,6 +2,7 @@ package simplelog
import (
"log"
"log/slog"
"os"
"github.com/mattn/go-isatty"
@ -16,8 +17,11 @@ type CustomLogger struct {
handlers []Handler
}
var ourCustomLogger *slog.Logger
func init() {
slog.SetDefaultLogger(NewCustomLogger())
ourCustomLogger = NewCustomLogger()
slog.SetDefault(ourCustomLogger)
}
func NewCustomLogger() *CustomLogger {

View File

@ -90,13 +90,6 @@ func (r *RELPHandler) connectToRELPServer() (net.Conn, error) {
}
return nil, err
}
conn, err = net.Dial("tcp", net.JoinHostPort(host, port))
if err != nil {
if relpDebug {
log.Printf("Failed to connect to RELP server at %s: %v", net.JoinHostPort(host, port), err)
}
return nil, err
}
if relpDebug {
log.Printf("Successfully connected to RELP server at %s", net.JoinHostPort(host, port))
}