mirror of
https://github.com/go-i2p/go-i2cp.git
synced 2025-12-01 06:54:57 -05:00
logger migration
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
=== RUN TestClient_CreateSession
|
=== RUN TestClient_CreateSession
|
||||||
Stream len 387
|
Stream len 387
|
||||||
Stream len 387
|
Stream len 387
|
||||||
--- PASS: TestClient_CreateSession (0.24s)
|
--- PASS: TestClient_CreateSession (0.22s)
|
||||||
=== RUN TestRandomDestination
|
=== RUN TestRandomDestination
|
||||||
Stream len 387
|
Stream len 387
|
||||||
Stream len 387
|
Stream len 387
|
||||||
@@ -43,4 +43,4 @@ Stream len 387
|
|||||||
Stream len 387
|
Stream len 387
|
||||||
--- PASS: TestSessionConfigIntegration (0.00s)
|
--- PASS: TestSessionConfigIntegration (0.00s)
|
||||||
PASS
|
PASS
|
||||||
ok github.com/go-i2p/go-i2cp 0.251s
|
ok github.com/go-i2p/go-i2cp 0.229s
|
||||||
|
|||||||
12
logger.go
12
logger.go
@@ -1,22 +1,28 @@
|
|||||||
package go_i2cp
|
package go_i2cp
|
||||||
|
|
||||||
import "fmt"
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/go-i2p/logger"
|
||||||
|
)
|
||||||
|
|
||||||
// LoggerTags defines the type for logger tags
|
// LoggerTags defines the type for logger tags
|
||||||
// Moved from: logger.go
|
// Moved from: logger.go
|
||||||
type LoggerTags = uint32
|
type LoggerTags = uint32
|
||||||
|
|
||||||
func (l *Logger) log(tags LoggerTags, format string, args ...interface{}) {
|
func (l *Logger) log(tags LoggerTags, format string, args ...interface{}) {
|
||||||
|
// Use go-i2p/logger exclusively
|
||||||
|
log := logger.GetGoI2PLogger()
|
||||||
if len(args) != 0 {
|
if len(args) != 0 {
|
||||||
if l.callbacks == nil {
|
if l.callbacks == nil {
|
||||||
fmt.Printf(format+"\n", args)
|
log.Warnf(format, args...)
|
||||||
} else {
|
} else {
|
||||||
l.callbacks.onLog(l, tags, fmt.Sprintf(format, args...))
|
l.callbacks.onLog(l, tags, fmt.Sprintf(format, args...))
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if l.callbacks == nil {
|
if l.callbacks == nil {
|
||||||
fmt.Println(format)
|
log.Warn(format)
|
||||||
} else {
|
} else {
|
||||||
l.callbacks.onLog(l, tags, format)
|
l.callbacks.onLog(l, tags, format)
|
||||||
}
|
}
|
||||||
|
|||||||
5
utils.go
5
utils.go
@@ -6,6 +6,8 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/go-i2p/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Moved from: session_config.go
|
// 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
|
// LogInit initializes the logger with callbacks and level
|
||||||
// TODO filter
|
// TODO filter
|
||||||
func LogInit(callbacks *LoggerCallbacks, level int) {
|
func LogInit(callbacks *LoggerCallbacks, level int) {
|
||||||
|
// Initialize go-i2p/logger
|
||||||
|
logger.InitializeGoI2PLogger()
|
||||||
|
|
||||||
switch level {
|
switch level {
|
||||||
case DEBUG:
|
case DEBUG:
|
||||||
os.Setenv("DEBUG_I2P", "debug")
|
os.Setenv("DEBUG_I2P", "debug")
|
||||||
|
|||||||
Reference in New Issue
Block a user