Merge branch 'master' into config-serde-defaults
This commit is contained in:
commit
68ab173ee8
8 files changed
+141
-15
No files matched your search
@@ -7,11 +7,15 @@ pub struct CommandsConfig {
|
||||
/// Are commands from the Console accepted ?
|
||||
#[serde_inline_default(true)]
|
||||
pub use_console: bool,
|
||||
// TODO: commands...
|
||||
/// Should be commands from players be logged in console?
|
||||
pub log_console: bool, // TODO: commands...
|
||||
}
|
||||
|
||||
impl Default for CommandsConfig {
|
||||
fn default() -> Self {
|
||||
Self { use_console: true }
|
||||
Self {
|
||||
use_console: true,
|
||||
log_console: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
use log::warn;
|
||||
use logging::LoggingConfig;
|
||||
use pumpkin_core::{Difficulty, GameMode};
|
||||
use serde::{de::DeserializeOwned, Deserialize, Serialize};
|
||||
|
||||
@@ -13,6 +14,7 @@ use std::{
|
||||
};
|
||||
|
||||
pub mod auth;
|
||||
pub mod logging;
|
||||
pub mod proxy;
|
||||
pub mod resource_pack;
|
||||
|
||||
@@ -56,6 +58,7 @@ pub struct AdvancedConfiguration {
|
||||
pub rcon: RCONConfig,
|
||||
#[serde(default)]
|
||||
pub pvp: PVPConfig,
|
||||
pub logging: LoggingConfig,
|
||||
}
|
||||
|
||||
#[serde_inline_default]
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub struct LoggingConfig {
|
||||
pub enabled: bool,
|
||||
pub level: LevelFilter,
|
||||
pub env: bool,
|
||||
pub threads: bool,
|
||||
pub color: bool,
|
||||
pub timestamp: bool,
|
||||
}
|
||||
|
||||
impl Default for LoggingConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
enabled: true,
|
||||
level: LevelFilter::Info,
|
||||
env: false,
|
||||
threads: true,
|
||||
color: true,
|
||||
timestamp: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
|
||||
pub enum LevelFilter {
|
||||
/// A level lower than all log levels.
|
||||
Off,
|
||||
/// Corresponds to the `Error` log level.
|
||||
Error,
|
||||
/// Corresponds to the `Warn` log level.
|
||||
Warn,
|
||||
/// Corresponds to the `Info` log level.
|
||||
Info,
|
||||
/// Corresponds to the `Debug` log level.
|
||||
Debug,
|
||||
/// Corresponds to the `Trace` log level.
|
||||
Trace,
|
||||
}
|
||||
@@ -19,6 +19,31 @@ pub struct RCONConfig {
|
||||
/// If 0 there is no limit
|
||||
#[serde(default)]
|
||||
pub max_connections: u32,
|
||||
/// RCON Logging
|
||||
pub logging: RCONLogging,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, Clone, Debug)]
|
||||
pub struct RCONLogging {
|
||||
/// Whether successful RCON logins should be logged.
|
||||
pub log_logged_successfully: bool,
|
||||
/// Whether failed RCON login attempts with incorrect passwords should be logged.
|
||||
pub log_wrong_password: bool,
|
||||
/// Whether all RCON commands, regardless of success or failure, should be logged.
|
||||
pub log_commands: bool,
|
||||
/// Whether RCON quit commands should be logged.
|
||||
pub log_quit: bool,
|
||||
}
|
||||
|
||||
impl Default for RCONLogging {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
log_logged_successfully: true,
|
||||
log_wrong_password: true,
|
||||
log_commands: true,
|
||||
log_quit: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn default_rcon_address() -> SocketAddr {
|
||||
@@ -32,6 +57,7 @@ impl Default for RCONConfig {
|
||||
address: default_rcon_address(),
|
||||
password: "".to_string(),
|
||||
max_connections: 0,
|
||||
logging: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user