fix: replace fmt.Sprintf in logger calls with structured fields and add LoopDelay default

fmt.Sprintf inside zap logger calls defeats structured logging,
making log aggregation and filtering harder. All 6 sites now use
proper zap fields (zap.Uint32, zap.Uint8, zap.String).

LoopDelay had no viper.SetDefault, so omitting it from config.json
caused a zero-value (0 ms) busy-loop in the recv loop. Default is
now 50 ms, matching config.example.json.
This commit is contained in:
Houmgaor
2026-02-22 16:32:43 +01:00
parent b3f75232a3
commit 1d507b3d11
6 changed files with 172 additions and 6 deletions

View File

@@ -109,7 +109,7 @@ func handleMsgSysGetFile(s *Session, p mhfpacket.MHFPacket) {
// Read the scenario file.
data, err := os.ReadFile(filepath.Join(s.server.erupeConfig.BinPath, fmt.Sprintf("scenarios/%s.bin", filename)))
if err != nil {
s.logger.Error(fmt.Sprintf("Failed to open file: %s/scenarios/%s.bin", s.server.erupeConfig.BinPath, filename))
s.logger.Error("Failed to open scenario file", zap.String("binPath", s.server.erupeConfig.BinPath), zap.String("filename", filename))
doAckBufFail(s, pkt.AckHandle, nil)
return
}
@@ -128,7 +128,7 @@ func handleMsgSysGetFile(s *Session, p mhfpacket.MHFPacket) {
data, err := os.ReadFile(filepath.Join(s.server.erupeConfig.BinPath, fmt.Sprintf("quests/%s.bin", pkt.Filename)))
if err != nil {
s.logger.Error(fmt.Sprintf("Failed to open file: %s/quests/%s.bin", s.server.erupeConfig.BinPath, pkt.Filename))
s.logger.Error("Failed to open quest file", zap.String("binPath", s.server.erupeConfig.BinPath), zap.String("filename", pkt.Filename))
doAckBufFail(s, pkt.AckHandle, nil)
return
}