Skip to content

Commit

Permalink
Add serde defaults for logging
Browse files Browse the repository at this point in the history
  • Loading branch information
lukas0008 committed Oct 11, 2024
1 parent 68ab173 commit 7db8c0e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
1 change: 1 addition & 0 deletions pumpkin-config/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pub struct CommandsConfig {
#[serde_inline_default(true)]
pub use_console: bool,
/// Should be commands from players be logged in console?
#[serde_inline_default(true)]
pub log_console: bool, // TODO: commands...
}

Expand Down
8 changes: 1 addition & 7 deletions pumpkin-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,14 @@ pub static BASIC_CONFIG: LazyLock<BasicConfiguration> = LazyLock::new(BasicConfi
/// This also allows you get some Performance or Resource boosts.
/// Important: The Configuration should match Vanilla by default
#[derive(Deserialize, Serialize, Default)]
#[serde(default)]
pub struct AdvancedConfiguration {
#[serde(default)]
pub proxy: ProxyConfig,
#[serde(default)]
pub authentication: AuthenticationConfig,
#[serde(default)]
pub packet_compression: CompressionConfig,
#[serde(default)]
pub resource_pack: ResourcePackConfig,
#[serde(default)]
pub commands: CommandsConfig,
#[serde(default)]
pub rcon: RCONConfig,
#[serde(default)]
pub pvp: PVPConfig,
pub logging: LoggingConfig,
}
Expand Down
8 changes: 8 additions & 0 deletions pumpkin-config/src/logging.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
use serde::{Deserialize, Serialize};
use serde_inline_default::serde_inline_default;

#[serde_inline_default]
#[derive(Deserialize, Serialize)]
pub struct LoggingConfig {
#[serde_inline_default(true)]
pub enabled: bool,
#[serde_inline_default(LevelFilter::Info)]
pub level: LevelFilter,
#[serde_inline_default(false)]
pub env: bool,
#[serde_inline_default(true)]
pub threads: bool,
#[serde_inline_default(true)]
pub color: bool,
#[serde_inline_default(true)]
pub timestamp: bool,
}

Expand Down
5 changes: 5 additions & 0 deletions pumpkin-config/src/rcon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,20 @@ pub struct RCONConfig {
pub logging: RCONLogging,
}

#[serde_inline_default]
#[derive(Deserialize, Serialize, Clone, Debug)]
pub struct RCONLogging {
/// Whether successful RCON logins should be logged.
#[serde_inline_default(true)]
pub log_logged_successfully: bool,
/// Whether failed RCON login attempts with incorrect passwords should be logged.
#[serde_inline_default(true)]
pub log_wrong_password: bool,
/// Whether all RCON commands, regardless of success or failure, should be logged.
#[serde_inline_default(true)]
pub log_commands: bool,
/// Whether RCON quit commands should be logged.
#[serde_inline_default(true)]
pub log_quit: bool,
}

Expand Down

0 comments on commit 7db8c0e

Please sign in to comment.