logger migration

This commit is contained in:
eyedeekay
2025-06-05 19:31:45 -04:00
parent 4a7051b9dd
commit a4e6d9b788
3 changed files with 16 additions and 5 deletions

View File

@@ -3,7 +3,7 @@
=== RUN TestClient_CreateSession
Stream len 387
Stream len 387
--- PASS: TestClient_CreateSession (0.24s)
--- PASS: TestClient_CreateSession (0.22s)
=== RUN TestRandomDestination
Stream len 387
Stream len 387
@@ -43,4 +43,4 @@ Stream len 387
Stream len 387
--- PASS: TestSessionConfigIntegration (0.00s)
PASS
ok github.com/go-i2p/go-i2cp 0.251s
ok github.com/go-i2p/go-i2cp 0.229s

View File

@@ -1,22 +1,28 @@
package go_i2cp
import "fmt"
import (
"fmt"
"github.com/go-i2p/logger"
)
// LoggerTags defines the type for logger tags
// Moved from: logger.go
type LoggerTags = uint32
func (l *Logger) log(tags LoggerTags, format string, args ...interface{}) {
// Use go-i2p/logger exclusively
log := logger.GetGoI2PLogger()
if len(args) != 0 {
if l.callbacks == nil {
fmt.Printf(format+"\n", args)
log.Warnf(format, args...)
} else {
l.callbacks.onLog(l, tags, fmt.Sprintf(format, args...))
}
return
}
if l.callbacks == nil {
fmt.Println(format)
log.Warn(format)
} else {
l.callbacks.onLog(l, tags, format)
}

View File

@@ -6,6 +6,8 @@ import (
"os"
"regexp"
"strings"
"github.com/go-i2p/logger"
)
// Moved from: session_config.go
@@ -17,6 +19,9 @@ var configRegex = regexp.MustCompile("\\s*([\\w.]+)=\\s*(.+)\\s*;\\s*")
// LogInit initializes the logger with callbacks and level
// TODO filter
func LogInit(callbacks *LoggerCallbacks, level int) {
// Initialize go-i2p/logger
logger.InitializeGoI2PLogger()
switch level {
case DEBUG:
os.Setenv("DEBUG_I2P", "debug")