From 1041cac476eec89dc0eed0f49e80539cc7e43455 Mon Sep 17 00:00:00 2001 From: Sophie Date: Sat, 7 Mar 2020 17:37:04 +0000 Subject: [PATCH] Add config option to log outbound messages --- config/config.go | 17 +++++++++-------- server/channelserver/session.go | 6 ++++-- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/config/config.go b/config/config.go index d44b3cb89..a71b07706 100644 --- a/config/config.go +++ b/config/config.go @@ -14,18 +14,19 @@ type Config struct { DevMode bool DevModeOptions DevModeOptions - Database Database - Launcher Launcher - Sign Sign - Channel Channel - Entrance Entrance + Database Database + Launcher Launcher + Sign Sign + Channel Channel + Entrance Entrance } // DevModeOptions holds various debug/temporary options for use while developing Erupe. type DevModeOptions struct { - CleanDB bool // Automatically wipes the DB on server reset. - MaxLauncherHR bool // Sets the HR returned in the launcher to HR9 so that you can join non-beginner worlds. - FixedStageID bool // Causes all move_stage to use the ID sl1Ns200p0a0u0 to get you into all stages + CleanDB bool // Automatically wipes the DB on server reset. + MaxLauncherHR bool // Sets the HR returned in the launcher to HR9 so that you can join non-beginner worlds. + FixedStageID bool // Causes all move_stage to use the ID sl1Ns200p0a0u0 to get you into all stages + LogOutboundMessages bool // Log all messages sent to the clients } // Database holds the postgres database config. diff --git a/server/channelserver/session.go b/server/channelserver/session.go index 1e7e1c47f..c7183ef8a 100644 --- a/server/channelserver/session.go +++ b/server/channelserver/session.go @@ -59,8 +59,10 @@ func (s *Session) Start() { // QueueSend queues a packet (raw []byte) to be sent. func (s *Session) QueueSend(data []byte) { - fmt.Printf("Sending To CharID: '%x'\n", s.charID) - fmt.Printf("Sent Data:\n%s\n", hex.Dump(data)) + if s.server.erupeConfig.DevMode && s.server.erupeConfig.DevModeOptions.LogOutboundMessages { + fmt.Printf("Sending To CharID: '%x'\n", s.charID) + fmt.Printf("Sent Data:\n%s\n", hex.Dump(data)) + } s.sendPackets <- data }