add LogMessageData DevModeOption & disable Logging by default

This commit is contained in:
wish
2023-11-20 00:58:24 +11:00
parent e9fa4e5261
commit 405e65346b
3 changed files with 11 additions and 5 deletions

View File

@@ -18,8 +18,9 @@
"AutoCreateAccount": true,
"CleanDB": false,
"MaxLauncherHR": false,
"LogInboundMessages": true,
"LogOutboundMessages": true,
"LogInboundMessages": false,
"LogOutboundMessages": false,
"LogMessageData": false,
"MaxHexdumpLength": 256,
"DivaEvent": 0,
"FestaEvent": -1,

View File

@@ -101,6 +101,7 @@ type DevModeOptions struct {
MaxLauncherHR bool // Sets the HR returned in the launcher to HR7 so that you can join non-beginner worlds.
LogInboundMessages bool // Log all messages sent to the server
LogOutboundMessages bool // Log all messages sent to the clients
LogMessageData bool // Log all bytes transferred as a hexdump
MaxHexdumpLength int // Maximum number of bytes printed when logs are enabled
DivaEvent int // Diva Defense event status
FestaEvent int // Hunter's Festa event status

View File

@@ -278,10 +278,14 @@ func (s *Session) logMessage(opcode uint16, data []byte, sender string, recipien
fmt.Printf("[%s] -> [%s]\n", sender, recipient)
}
fmt.Printf("Opcode: %s\n", opcodePID)
if len(data) <= s.server.erupeConfig.DevModeOptions.MaxHexdumpLength {
fmt.Printf("Data [%d bytes]:\n%s\n", len(data), hex.Dump(data))
if s.server.erupeConfig.DevModeOptions.LogMessageData {
if len(data) <= s.server.erupeConfig.DevModeOptions.MaxHexdumpLength {
fmt.Printf("Data [%d bytes]:\n%s\n", len(data), hex.Dump(data))
} else {
fmt.Printf("Data [%d bytes]: (Too long!)\n\n", len(data))
}
} else {
fmt.Printf("Data [%d bytes]: (Too long!)\n\n", len(data))
fmt.Printf("\n")
}
}