refactor: standardize logging on zap across all packages

Replace all fmt.Printf/Println and log.Printf/Fatal with structured
zap.Logger calls to eliminate inconsistent logging (anti-pattern #12).

- network/crypt_conn: inject logger via NewCryptConn, replace 6 fmt calls
- signserver/session: use existing s.logger for debug packet dumps
- entranceserver: use s.logger for inbound/outbound debug logging
- api/utils: accept logger param in verifyPath, replace fmt.Println
- api/endpoints: use s.logger for screenshot path diagnostics
- config: replace log.Fatal with error return in getOutboundIP4
- deltacomp: replace log.Printf with zap.L() global logger
This commit is contained in:
Houmgaor
2026-02-20 18:59:12 +01:00
parent e5133e5dcf
commit 06cb3afa57
15 changed files with 134 additions and 117 deletions

View File

@@ -108,14 +108,14 @@ func TestVersionStringsContent(t *testing.T) {
index int
expected string
}{
{0, "S1.0"}, // S1
{14, "S10"}, // S10
{15, "FW.1"}, // F1
{19, "FW.5"}, // F5
{20, "G1"}, // G1
{38, "Z1"}, // Z1
{39, "Z2"}, // Z2
{40, "ZZ"}, // ZZ
{0, "S1.0"}, // S1
{14, "S10"}, // S10
{15, "FW.1"}, // F1
{19, "FW.5"}, // F5
{20, "G1"}, // G1
{38, "Z1"}, // Z1
{39, "Z2"}, // Z2
{40, "ZZ"}, // ZZ
}
for _, tt := range tests {
@@ -127,7 +127,10 @@ func TestVersionStringsContent(t *testing.T) {
// TestGetOutboundIP4 tests IP detection
func TestGetOutboundIP4(t *testing.T) {
ip := getOutboundIP4()
ip, err := getOutboundIP4()
if err != nil {
t.Fatalf("getOutboundIP4() returned error: %v", err)
}
if ip == nil {
t.Error("getOutboundIP4() returned nil IP")
}
@@ -276,17 +279,17 @@ func TestDebugOptions(t *testing.T) {
// TestGameplayOptions verifies GameplayOptions struct
func TestGameplayOptions(t *testing.T) {
opts := GameplayOptions{
MinFeatureWeapons: 2,
MaxFeatureWeapons: 10,
MaximumNP: 999999,
MaximumRP: 9999,
MaximumFP: 999999999,
MezFesSoloTickets: 100,
MezFesGroupTickets: 50,
DisableHunterNavi: true,
EnableKaijiEvent: true,
EnableHiganjimaEvent: false,
EnableNierEvent: false,
MinFeatureWeapons: 2,
MaxFeatureWeapons: 10,
MaximumNP: 999999,
MaximumRP: 9999,
MaximumFP: 999999999,
MezFesSoloTickets: 100,
MezFesGroupTickets: 50,
DisableHunterNavi: true,
EnableKaijiEvent: true,
EnableHiganjimaEvent: false,
EnableNierEvent: false,
}
if opts.MinFeatureWeapons != 2 {
@@ -486,12 +489,12 @@ func TestEntrance(t *testing.T) {
// TestEntranceServerInfo verifies EntranceServerInfo struct
func TestEntranceServerInfo(t *testing.T) {
info := EntranceServerInfo{
IP: "192.168.1.1",
Type: 1,
Season: 0,
Recommended: 0,
Name: "Server 1",
Description: "Main server",
IP: "192.168.1.1",
Type: 1,
Season: 0,
Recommended: 0,
Name: "Server 1",
Description: "Main server",
AllowedClientFlags: 4096,
Channels: []EntranceChannelInfo{
{Port: 10001, MaxPlayers: 4, CurrentPlayers: 2},
@@ -624,9 +627,9 @@ func TestGameplayOptionsConstraints(t *testing.T) {
{
name: "valid multipliers",
opts: GameplayOptions{
HRPMultiplier: 1.5,
GRPMultiplier: 1.2,
ZennyMultiplier: 1.0,
HRPMultiplier: 1.5,
GRPMultiplier: 1.2,
ZennyMultiplier: 1.0,
MaterialMultiplier: 1.3,
},
ok: true,
@@ -671,7 +674,7 @@ func TestModeValueRanges(t *testing.T) {
// TestConfigDefaults tests default configuration creation
func TestConfigDefaults(t *testing.T) {
cfg := &Config{
ClientMode: "ZZ",
ClientMode: "ZZ",
RealClientMode: ZZ,
}
@@ -696,7 +699,6 @@ func BenchmarkModeString(b *testing.B) {
func BenchmarkGetOutboundIP4(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
_ = getOutboundIP4()
_, _ = getOutboundIP4()
}
}