Refactored logging to use custom logger and set default logger.
This commit is contained in:
parent
24c6ebe407
commit
f8bd3147a4
|
@ -2,6 +2,7 @@ package simplelog
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
"log/slog"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/mattn/go-isatty"
|
"github.com/mattn/go-isatty"
|
||||||
|
@ -16,8 +17,11 @@ type CustomLogger struct {
|
||||||
handlers []Handler
|
handlers []Handler
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var ourCustomLogger *slog.Logger
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
slog.SetDefaultLogger(NewCustomLogger())
|
ourCustomLogger = NewCustomLogger()
|
||||||
|
slog.SetDefault(ourCustomLogger)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewCustomLogger() *CustomLogger {
|
func NewCustomLogger() *CustomLogger {
|
||||||
|
|
|
@ -90,13 +90,6 @@ func (r *RELPHandler) connectToRELPServer() (net.Conn, error) {
|
||||||
}
|
}
|
||||||
return nil, err
|
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 {
|
if relpDebug {
|
||||||
log.Printf("Successfully connected to RELP server at %s", net.JoinHostPort(host, port))
|
log.Printf("Successfully connected to RELP server at %s", net.JoinHostPort(host, port))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue