Skip to content

Commit 9aeaaa1

Browse files
author
trident
committed
Logging bug fix
1 parent 8e1bc40 commit 9aeaaa1

File tree

2 files changed

+24
-12
lines changed

2 files changed

+24
-12
lines changed

crates/game_server/src/server/core.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ impl GameServer {
127127
}
128128

129129
// Initialize plugin manager with safety configuration and GORC support
130-
let plugin_manager = Arc::new(PluginManager::with_gorc(horizon_event_system.clone(), config.plugin_safety.clone(), gorc_instance_manager.clone()));
130+
let plugin_manager = Arc::new(PluginManager::with_gorc(horizon_event_system.clone(), config.plugin_safety.clone(), gorc_instance_manager.clone(), log_level));
131131

132132
// Initialize GORC components
133133
let gorc_manager = Arc::new(GorcManager::new());

crates/plugin_system/src/manager.rs

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ struct BasicServerContext {
3636
region_id: horizon_event_system::types::RegionId,
3737
luminal_handle: luminal::Handle,
3838
gorc_instance_manager: Option<Arc<horizon_event_system::gorc::GorcInstanceManager>>,
39+
log_level: horizon_event_system::LogLevel,
3940
}
4041

4142
impl std::fmt::Debug for BasicServerContext {
@@ -48,56 +49,60 @@ impl std::fmt::Debug for BasicServerContext {
4849

4950
impl BasicServerContext {
5051
/// Create a new basic context with a specific region.
51-
fn new(event_system: Arc<EventSystem>) -> Self {
52+
fn new(event_system: Arc<EventSystem>, log_level: horizon_event_system::LogLevel) -> Self {
5253
let luminal_rt = luminal::Runtime::new().expect("Failed to create luminal runtime");
5354
Self {
5455
event_system,
5556
region_id: horizon_event_system::types::RegionId::default(),
5657
luminal_handle: luminal_rt.handle().clone(),
5758
gorc_instance_manager: None,
59+
log_level,
5860
}
5961
}
6062

6163
/// Create a context with a custom region id.
6264
#[allow(dead_code)]
63-
fn with_region(event_system: Arc<EventSystem>, region_id: horizon_event_system::types::RegionId) -> Self {
65+
fn with_region(event_system: Arc<EventSystem>, region_id: horizon_event_system::types::RegionId, log_level: horizon_event_system::LogLevel) -> Self {
6466
let luminal_rt = luminal::Runtime::new().expect("Failed to create luminal runtime");
6567
Self {
6668
event_system,
6769
region_id,
6870
luminal_handle: luminal_rt.handle().clone(),
6971
gorc_instance_manager: None,
72+
log_level,
7073
}
7174
}
7275

7376
/// Create a context with an explicit luminal handle.
7477
#[allow(dead_code)]
75-
fn with_luminal_handle(event_system: Arc<EventSystem>, luminal_handle: luminal::Handle) -> Self {
78+
fn with_luminal_handle(event_system: Arc<EventSystem>, luminal_handle: luminal::Handle, log_level: horizon_event_system::LogLevel) -> Self {
7679
Self {
7780
event_system,
7881
region_id: horizon_event_system::types::RegionId::default(),
7982
luminal_handle: luminal_handle,
8083
gorc_instance_manager: None,
84+
log_level,
8185
}
8286
}
8387

8488
/// Create a context with a GORC instance manager.
8589
#[allow(dead_code)]
86-
fn with_gorc(event_system: Arc<EventSystem>, gorc_instance_manager: Arc<horizon_event_system::gorc::GorcInstanceManager>) -> Self {
90+
fn with_gorc(event_system: Arc<EventSystem>, gorc_instance_manager: Arc<horizon_event_system::gorc::GorcInstanceManager>, log_level: horizon_event_system::LogLevel) -> Self {
8791
let luminal_rt = luminal::Runtime::new().expect("Failed to create luminal runtime");
8892
Self {
8993
event_system,
9094
region_id: horizon_event_system::types::RegionId::default(),
9195
luminal_handle: luminal_rt.handle().clone(),
9296
gorc_instance_manager: Some(gorc_instance_manager),
97+
log_level,
9398
}
9499
}
95100
}
96101

97102
#[async_trait::async_trait]
98103
impl ServerContext for BasicServerContext {
99104
fn log_level(&self) -> horizon_event_system::LogLevel {
100-
horizon_event_system::LogLevel::Info
105+
self.log_level
101106
}
102107
fn events(&self) -> Arc<EventSystem> {
103108
self.event_system.clone()
@@ -165,6 +170,8 @@ pub struct PluginManager {
165170
safety_config: PluginSafetyConfig,
166171
/// Optional GORC instance manager for object replication
167172
gorc_instance_manager: Option<Arc<horizon_event_system::gorc::GorcInstanceManager>>,
173+
/// Log level for plugins
174+
log_level: horizon_event_system::LogLevel,
168175
}
169176

170177
impl PluginManager {
@@ -174,16 +181,18 @@ impl PluginManager {
174181
///
175182
/// * `event_system` - The event system that plugins will use for communication
176183
/// * `safety_config` - Configuration for plugin loading safety checks
184+
/// * `log_level` - Log level for plugin contexts
177185
///
178186
/// # Returns
179187
///
180188
/// A new `PluginManager` instance ready to load plugins.
181-
pub fn new(event_system: Arc<EventSystem>, safety_config: PluginSafetyConfig) -> Self {
189+
pub fn new(event_system: Arc<EventSystem>, safety_config: PluginSafetyConfig, log_level: horizon_event_system::LogLevel) -> Self {
182190
Self {
183191
event_system,
184192
loaded_plugins: DashMap::new(),
185193
safety_config,
186194
gorc_instance_manager: None,
195+
log_level,
187196
}
188197
}
189198

@@ -194,20 +203,23 @@ impl PluginManager {
194203
/// * `event_system` - The event system that plugins will use for communication
195204
/// * `safety_config` - Configuration for plugin loading safety checks
196205
/// * `gorc_instance_manager` - GORC instance manager for object replication
206+
/// * `log_level` - Log level for plugin contexts
197207
///
198208
/// # Returns
199209
///
200210
/// A new `PluginManager` instance ready to load plugins with GORC support.
201211
pub fn with_gorc(
202212
event_system: Arc<EventSystem>,
203213
safety_config: PluginSafetyConfig,
204-
gorc_instance_manager: Arc<horizon_event_system::gorc::GorcInstanceManager>
214+
gorc_instance_manager: Arc<horizon_event_system::gorc::GorcInstanceManager>,
215+
log_level: horizon_event_system::LogLevel,
205216
) -> Self {
206217
Self {
207218
event_system,
208219
loaded_plugins: DashMap::new(),
209220
safety_config,
210221
gorc_instance_manager: Some(gorc_instance_manager),
222+
log_level,
211223
}
212224
}
213225

@@ -436,9 +448,9 @@ impl PluginManager {
436448
info!("🔧 Initializing {} loaded plugins", self.loaded_plugins.len());
437449

438450
let context = if let Some(gorc_manager) = &self.gorc_instance_manager {
439-
Arc::new(BasicServerContext::with_gorc(self.event_system.clone(), gorc_manager.clone()))
451+
Arc::new(BasicServerContext::with_gorc(self.event_system.clone(), gorc_manager.clone(), self.log_level))
440452
} else {
441-
Arc::new(BasicServerContext::new(self.event_system.clone()))
453+
Arc::new(BasicServerContext::new(self.event_system.clone(), self.log_level))
442454
};
443455

444456
// Phase 1: Pre-initialization (register handlers)
@@ -488,9 +500,9 @@ impl PluginManager {
488500
info!("🛑 Shutting down {} plugins", self.loaded_plugins.len());
489501

490502
let context = if let Some(gorc_manager) = &self.gorc_instance_manager {
491-
Arc::new(BasicServerContext::with_gorc(self.event_system.clone(), gorc_manager.clone()))
503+
Arc::new(BasicServerContext::with_gorc(self.event_system.clone(), gorc_manager.clone(), self.log_level))
492504
} else {
493-
Arc::new(BasicServerContext::new(self.event_system.clone()))
505+
Arc::new(BasicServerContext::new(self.event_system.clone(), self.log_level))
494506
};
495507

496508
// Call shutdown on all plugins and collect libraries for controlled cleanup

0 commit comments

Comments
 (0)