From ccb78eeb5cdfbde36cf3ee88297e7783ce105199 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=A4rtens?= Date: Mon, 29 Mar 2021 01:40:53 +0200 Subject: [PATCH] move tracing code to own crate --- Cargo.lock | 25 ++-- Cargo.toml | 1 + client/Cargo.toml | 8 +- client/examples/chat-cli/main.rs | 2 +- client/src/bin/bot/main.rs | 2 +- client/src/bin/bot/tui.rs | 15 -- common/frontend/Cargo.toml | 22 +++ .../logging.rs => common/frontend/src/lib.rs | 132 ++++++++++-------- server-cli/Cargo.toml | 8 +- server-cli/src/logging.rs | 68 --------- server-cli/src/main.rs | 15 +- server-cli/src/tui_runner.rs | 2 +- voxygen/Cargo.toml | 10 +- voxygen/src/hud/mod.rs | 4 + voxygen/src/lib.rs | 1 - voxygen/src/main.rs | 4 +- voxygen/src/menu/main/client_init.rs | 1 + voxygen/src/menu/main/mod.rs | 7 +- 18 files changed, 144 insertions(+), 183 deletions(-) create mode 100644 common/frontend/Cargo.toml rename voxygen/src/logging.rs => common/frontend/src/lib.rs (51%) delete mode 100644 server-cli/src/logging.rs diff --git a/Cargo.lock b/Cargo.lock index 86541ce91a..57b6c0fe7a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5342,11 +5342,11 @@ dependencies = [ "termcolor", "tokio", "tracing", - "tracing-subscriber", "vek", "veloren-common", "veloren-common-base", "veloren-common-ecs", + "veloren-common-frontend", "veloren-common-net", "veloren-common-sys", "veloren-network", @@ -5411,6 +5411,19 @@ dependencies = [ "veloren-common-base", ] +[[package]] +name = "veloren-common-frontend" +version = "0.9.0" +dependencies = [ + "termcolor", + "tracing", + "tracing-appender", + "tracing-log", + "tracing-subscriber", + "tracing-tracy", + "veloren-common-base", +] + [[package]] name = "veloren-common-net" version = "0.9.0" @@ -5575,14 +5588,12 @@ dependencies = [ "ron", "serde", "signal-hook 0.3.7", - "termcolor", "tokio", "tracing", - "tracing-subscriber", - "tracing-tracy", "tui", "veloren-common", "veloren-common-base", + "veloren-common-frontend", "veloren-common-net", "veloren-server", ] @@ -5634,19 +5645,15 @@ dependencies = [ "serde", "specs", "specs-idvs", - "termcolor", "tokio", "tracing", - "tracing-appender", - "tracing-log", - "tracing-subscriber", - "tracing-tracy", "treeculler", "vek", "veloren-client", "veloren-common", "veloren-common-base", "veloren-common-ecs", + "veloren-common-frontend", "veloren-common-net", "veloren-common-sys", "veloren-server", diff --git a/Cargo.toml b/Cargo.toml index 1a18a76a08..2c7b8a0bbe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,6 +7,7 @@ members = [ "common/ecs", "common/net", "common/sys", + "common/frontend", "client", "plugin/api", "plugin/derive", diff --git a/client/Cargo.toml b/client/Cargo.toml index 6c17fd38a0..ff1d1237d9 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -5,10 +5,10 @@ authors = ["Joshua Barretto "] edition = "2018" [features] -tracy = ["common/tracy", "common-base/tracy", "common-sys/tracy", "common-net/tracy"] +tracy = ["common/tracy", "common-base/tracy", "common-sys/tracy", "common-net/tracy", "common-frontend/tracy"] simd = ["vek/platform_intrinsics"] plugins = ["common-sys/plugins"] -bin_bot = ["common-ecs", "serde", "ron", "clap", "rustyline", "termcolor", "tracing-subscriber", "async-channel"] +bin_bot = ["common-ecs", "serde", "ron", "clap", "rustyline", "common-frontend", "async-channel"] default = ["simd"] @@ -40,13 +40,13 @@ clap = { version = "2.33", optional = true } rustyline = { version = "8.0.0", optional = true } ## logging termcolor = { version = "1.1", optional = true } -tracing-subscriber = {version = "0.2.3", default-features = false, features = ["env-filter", "fmt", "chrono", "ansi", "smallvec", "tracing-log"], optional = true } +common-frontend = { package = "veloren-common-frontend", path = "../common/frontend", optional = true } [dev-dependencies] -tracing-subscriber = { version = "0.2.3", default-features = false, features = ["fmt", "chrono", "ansi", "smallvec"] } [[example]] name = "chat-cli" +required-features = ["bin_bot"] [[bin]] name = "bot" diff --git a/client/examples/chat-cli/main.rs b/client/examples/chat-cli/main.rs index 495930c0b9..e22fdb963f 100644 --- a/client/examples/chat-cli/main.rs +++ b/client/examples/chat-cli/main.rs @@ -27,7 +27,7 @@ fn read_input() -> String { fn main() { // Initialize logging. - tracing_subscriber::fmt::init(); + common_frontend::init_stdout(None); info!("Starting chat-cli..."); diff --git a/client/src/bin/bot/main.rs b/client/src/bin/bot/main.rs index 1e5ff3ae4c..a9ae28f1e8 100644 --- a/client/src/bin/bot/main.rs +++ b/client/src/bin/bot/main.rs @@ -24,7 +24,7 @@ pub struct BotCreds { } pub fn main() { - tui::init_logging(); + common_frontend::init_stdout(None); let settings = Settings::load(); info!("Settings: {:?}", settings); diff --git a/client/src/bin/bot/tui.rs b/client/src/bin/bot/tui.rs index 7105f637b3..bb55168930 100644 --- a/client/src/bin/bot/tui.rs +++ b/client/src/bin/bot/tui.rs @@ -2,21 +2,6 @@ use clap::{App, AppSettings, Arg, SubCommand}; use std::{thread, time::Duration}; use tracing::error; -pub fn init_logging() { - use termcolor::{ColorChoice, StandardStream}; - use tracing::Level; - use tracing_subscriber::{filter::LevelFilter, EnvFilter, FmtSubscriber}; - const RUST_LOG_ENV: &str = "RUST_LOG"; - let filter = EnvFilter::from_env(RUST_LOG_ENV).add_directive(LevelFilter::INFO.into()); - let subscriber = FmtSubscriber::builder() - .with_max_level(Level::ERROR) - .with_env_filter(filter); - - subscriber - .with_writer(|| StandardStream::stdout(ColorChoice::Auto)) - .init(); -} - pub enum Cmd { Register { prefix: String, diff --git a/common/frontend/Cargo.toml b/common/frontend/Cargo.toml new file mode 100644 index 0000000000..83c06a72b4 --- /dev/null +++ b/common/frontend/Cargo.toml @@ -0,0 +1,22 @@ +[package] +authors = ["Marcel Märtens ", "Imbris "] +edition = "2018" +name = "veloren-common-frontend" +description = "common stuff that is used by server-cli and voxygen directly" +version = "0.9.0" + +[features] +tracy = ["common-base/tracy", "tracing-tracy"] + +[dependencies] +common-base = { package = "veloren-common-base", path = "../base" } + +# Logging +termcolor = "1.1" +tracing = { version = "0.1", default-features = false } +tracing-appender = "0.1" +tracing-log = "0.1.1" +tracing-subscriber = { version = "0.2.3", default-features = false, features = ["env-filter", "fmt", "chrono", "ansi", "smallvec", "tracing-log"]} + +# Tracy +tracing-tracy = { version = "0.6.0", optional = true } \ No newline at end of file diff --git a/voxygen/src/logging.rs b/common/frontend/src/lib.rs similarity index 51% rename from voxygen/src/logging.rs rename to common/frontend/src/lib.rs index f0b3817b71..69683454f6 100644 --- a/voxygen/src/logging.rs +++ b/common/frontend/src/lib.rs @@ -1,14 +1,16 @@ -use std::fs; - -use crate::settings::Settings; +#[cfg(not(feature = "tracy"))] use std::fs; +use std::path::Path; use termcolor::{ColorChoice, StandardStream}; -use tracing::{debug, error, info, trace}; -use tracing_subscriber::{filter::LevelFilter, prelude::*, registry, EnvFilter}; +use tracing::info; +use tracing_appender::non_blocking::WorkerGuard; +use tracing_subscriber::{ + filter::LevelFilter, fmt::writer::MakeWriter, prelude::*, registry, EnvFilter, +}; const RUST_LOG_ENV: &str = "RUST_LOG"; -/// Initialise tracing and logging for the settings. +/// Initialise tracing and logging for the logs_path. /// /// This function will attempt to set up both a file and a terminal logger, /// falling back to just a terminal logger if the file is unable to be created. @@ -30,10 +32,14 @@ const RUST_LOG_ENV: &str = "RUST_LOG"; /// /// By default a few directives are set to `warn` by default, until explicitly /// overwritten! e.g. `RUST_LOG="gfx_device_gl=debug"` -pub fn init(settings: &Settings) -> Vec { +pub fn init(log_path_file: Option<(&Path, &str)>, terminal: W2) -> Vec +where + W2: MakeWriter + 'static, + ::Writer: Send + Sync, +{ // To hold the guards that we create, they will cause the logs to be // flushed when they're dropped. - let mut _guards = vec![]; + let mut _guards: Vec = vec![]; // We will do lower logging than the default (INFO) by INCLUSION. This // means that if you need lower level logging for a specific module, then @@ -42,7 +48,11 @@ pub fn init(settings: &Settings) -> Vec { let base_exceptions = |env: EnvFilter| { env.add_directive("dot_vox::parser=warn".parse().unwrap()) .add_directive("gfx_device_gl=warn".parse().unwrap()) - .add_directive("prometheus_hyper=warn".parse().unwrap()) + .add_directive("veloren_world::sim=info".parse().unwrap()) + .add_directive("veloren_world::civ=info".parse().unwrap()) + .add_directive("hyper=info".parse().unwrap()) + .add_directive("prometheus_hyper=info".parse().unwrap()) + .add_directive("mio::pool=info".parse().unwrap()) .add_directive("mio::sys::windows=info".parse().unwrap()) .add_directive("h2=info".parse().unwrap()) .add_directive("tokio_util=info".parse().unwrap()) @@ -56,7 +66,6 @@ pub fn init(settings: &Settings) -> Vec { .add_directive(LevelFilter::INFO.into()) }; - #[cfg(not(feature = "tracy"))] let filter = match std::env::var_os(RUST_LOG_ENV).map(|s| s.into_string()) { Some(Ok(env)) => { let mut filter = base_exceptions(EnvFilter::new("")); @@ -71,63 +80,68 @@ pub fn init(settings: &Settings) -> Vec { _ => base_exceptions(EnvFilter::from_env(RUST_LOG_ENV)), }; + let registry = registry(); + #[cfg(not(feature = "tracy"))] + let mut file_setup = false; #[cfg(feature = "tracy")] - let filter = base_exceptions(EnvFilter::new("")).add_directive(LevelFilter::INFO.into()); + let file_setup = false; + #[cfg(feature = "tracy")] + let _terminal = terminal; // Create the terminal writer layer. - let (non_blocking, _stdio_guard) = - tracing_appender::non_blocking(StandardStream::stdout(ColorChoice::Auto)); - _guards.push(_stdio_guard); + #[cfg(feature = "tracy")] + let registry = registry.with(tracing_tracy::TracyLayer::new().with_stackdepth(0)); + #[cfg(not(feature = "tracy"))] + let registry = { + let (non_blocking, _stdio_guard) = tracing_appender::non_blocking(terminal.make_writer()); + _guards.push(_stdio_guard); + registry.with(tracing_subscriber::fmt::layer().with_writer(non_blocking)) + }; // Try to create the log file's parent folders. - let log_folders_created = fs::create_dir_all(&settings.log.logs_path); - const LOG_FILENAME: &str = "voxygen.log"; + #[cfg(not(feature = "tracy"))] + if let Some((path, file)) = log_path_file { + match fs::create_dir_all(path) { + Ok(_) => { + let file_appender = tracing_appender::rolling::daily(path, file); + let (non_blocking_file, _file_guard) = + tracing_appender::non_blocking(file_appender); + _guards.push(_file_guard); + file_setup = true; + registry + .with(tracing_subscriber::fmt::layer().with_writer(non_blocking_file)) + .with(filter) + .init(); + }, + Err(e) => { + tracing::error!( + ?e, + "Failed to create log file!. Falling back to terminal logging only.", + ); + registry.with(filter).init(); + }, + } + } else { + registry.with(filter).init(); + } + #[cfg(feature = "tracy")] + registry.with(filter).init(); - match log_folders_created { - // If the parent folders were created then attach both a terminal and a - // file writer to the registry and init it. - Ok(_) => { - let file_appender = - tracing_appender::rolling::daily(&settings.log.logs_path, LOG_FILENAME); - let (non_blocking_file, _file_guard) = tracing_appender::non_blocking(file_appender); - _guards.push(_file_guard); - #[cfg(not(feature = "tracy"))] - registry() - .with(tracing_subscriber::fmt::layer().with_writer(non_blocking)) - .with(tracing_subscriber::fmt::layer().with_writer(non_blocking_file)) - .with(filter) - .init(); - #[cfg(feature = "tracy")] - registry() - // NOTE: collecting stacks has a significant overhead (x6 overhead of - // starting/stopping a span through the layer interface) - .with(tracing_tracy::TracyLayer::new().with_stackdepth(0)) - .with(filter) - .init(); - let logdir = &settings.log.logs_path; - info!(?logdir, "Setup terminal and file logging."); - }, - // Otherwise just add a terminal writer and init it. - Err(e) => { - error!( - ?e, - "Failed to create log file!. Falling back to terminal logging only.", - ); - #[cfg(not(feature = "tracy"))] - registry() - .with(tracing_subscriber::fmt::layer().with_writer(non_blocking)) - .with(filter); - #[cfg(feature = "tracy")] - registry() - .with(tracing_tracy::TracyLayer::new().with_stackdepth(0)) - .with(filter) - .init(); - info!("Setup terminal logging."); - }, + if file_setup { + let (path, file) = log_path_file.unwrap(); + info!(?path, ?file, "Setup terminal and file logging."); + } + + if tracing::level_enabled!(tracing::Level::TRACE) { + info!("Tracing Level: TRACE"); + } else if tracing::level_enabled!(tracing::Level::DEBUG) { + info!("Tracing Level: DEBUG"); }; - debug!("Tracing is successfully set to DEBUG or TRACE"); - trace!("Tracing is successfully set to TRACE"); // Return the guards _guards } + +pub fn init_stdout(log_path_file: Option<(&Path, &str)>) -> Vec { + init(log_path_file, || StandardStream::stdout(ColorChoice::Auto)) +} diff --git a/server-cli/Cargo.toml b/server-cli/Cargo.toml index d7c22484fb..3fa9f0c894 100644 --- a/server-cli/Cargo.toml +++ b/server-cli/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [features] worldgen = ["server/worldgen"] default = ["worldgen"] -tracy = ["common/tracy", "tracing-tracy", "server/tracy", "common-net/tracy"] +tracy = ["common/tracy", "server/tracy", "common-net/tracy", "common-frontend/tracy"] plugins = ["server/plugins"] [dependencies] @@ -15,6 +15,7 @@ server = { package = "veloren-server", path = "../server", default-features = fa common = { package = "veloren-common", path = "../common" } common-base = { package = "veloren-common-base", path = "../common/base" } common-net = { package = "veloren-common-net", path = "../common/net" } +common-frontend = { package = "veloren-common-frontend", path = "../common/frontend" } tokio = { version = "1", default-features = false, features = ["rt-multi-thread"] } ansi-parser = "0.7" @@ -22,15 +23,10 @@ clap = "2.33" crossterm = "0.19" lazy_static = "1" signal-hook = "0.3.6" -termcolor = "1.1" tracing = { version = "0.1", default-features = false } -tracing-subscriber = { version = "0.2.3", default-features = false, features = ["env-filter", "fmt", "chrono", "ansi", "smallvec"] } ron = {version = "0.6", default-features = false} serde = {version = "1.0", features = [ "rc", "derive" ]} -# Tracy -tracing-tracy = { version = "0.6.0", optional = true } - [dependencies.tui] git = "https://github.com/fdehau/tui-rs.git" branch="paragraph-scroll" diff --git a/server-cli/src/logging.rs b/server-cli/src/logging.rs deleted file mode 100644 index 356e9938b2..0000000000 --- a/server-cli/src/logging.rs +++ /dev/null @@ -1,68 +0,0 @@ -use crate::tuilog::TuiLog; -use termcolor::{ColorChoice, StandardStream}; -use tracing_subscriber::{filter::LevelFilter, EnvFilter, FmtSubscriber}; -#[cfg(feature = "tracy")] -use tracing_subscriber::{layer::SubscriberExt, prelude::*}; - -const RUST_LOG_ENV: &str = "RUST_LOG"; - -lazy_static::lazy_static! { - pub static ref LOG: TuiLog<'static> = TuiLog::default(); -} - -pub fn init(basic: bool) { - // Init logging - let base_exceptions = |env: EnvFilter| { - env.add_directive("veloren_world::sim=info".parse().unwrap()) - .add_directive("veloren_world::civ=info".parse().unwrap()) - .add_directive("hyper=info".parse().unwrap()) - .add_directive("prometheus_hyper=info".parse().unwrap()) - .add_directive("mio::pool=info".parse().unwrap()) - .add_directive("mio::sys::windows=info".parse().unwrap()) - .add_directive("h2=info".parse().unwrap()) - .add_directive("tokio_util=info".parse().unwrap()) - .add_directive("rustls=info".parse().unwrap()) - .add_directive("veloren_network_protocol=info".parse().unwrap()) - .add_directive( - "veloren_server::persistence::character=info" - .parse() - .unwrap(), - ) - .add_directive(LevelFilter::INFO.into()) - }; - - let filter = match std::env::var_os(RUST_LOG_ENV).map(|s| s.into_string()) { - Some(Ok(env)) => { - let mut filter = base_exceptions(EnvFilter::new("")); - for s in env.split(',').into_iter() { - match s.parse() { - Ok(d) => filter = filter.add_directive(d), - Err(err) => println!("WARN ignoring log directive: `{}`: {}", s, err), - }; - } - filter - }, - _ => base_exceptions(EnvFilter::from_env(RUST_LOG_ENV)), - }; - - #[cfg(feature = "tracy")] - tracing_subscriber::registry() - .with(filter) - .with(tracing_tracy::TracyLayer::new().with_stackdepth(0)) - .init(); - - #[cfg(not(feature = "tracy"))] - // TODO: when tracing gets per Layer filters re-enable this when the tracy feature is being - // used (and do the same in voxygen) - { - let subscriber = FmtSubscriber::builder().with_env_filter(filter); - - if basic { - subscriber - .with_writer(|| StandardStream::stdout(ColorChoice::Auto)) - .init(); - } else { - subscriber.with_writer(|| LOG.clone()).init(); - } - } -} diff --git a/server-cli/src/main.rs b/server-cli/src/main.rs index 9258a71c82..03f5fa421e 100644 --- a/server-cli/src/main.rs +++ b/server-cli/src/main.rs @@ -6,13 +6,13 @@ mod admin; /// `server-cli` interface commands not to be confused with the commands sent /// from the client to the server mod cmd; -mod logging; mod settings; mod shutdown_coordinator; mod tui_runner; mod tuilog; - -use crate::{cmd::Message, shutdown_coordinator::ShutdownCoordinator, tui_runner::Tui}; +use crate::{ + cmd::Message, shutdown_coordinator::ShutdownCoordinator, tui_runner::Tui, tuilog::TuiLog, +}; use clap::{App, Arg, SubCommand}; use common::clock::Clock; use common_base::span; @@ -25,6 +25,9 @@ use std::{ }; use tracing::{info, trace}; +lazy_static::lazy_static! { + pub static ref LOG: TuiLog<'static> = TuiLog::default(); +} const TPS: u64 = 30; #[allow(clippy::unnecessary_wraps)] @@ -83,7 +86,11 @@ fn main() -> io::Result<()> { #[cfg(any(target_os = "linux", target_os = "macos"))] let _ = signal_hook::flag::register(signal_hook::consts::SIGUSR1, Arc::clone(&sigusr1_signal)); - logging::init(basic); + let (_guards, _guards2) = if basic { + (vec![], common_frontend::init_stdout(None)) + } else { + (common_frontend::init(None, || LOG.clone()), vec![]) + }; // Load settings let settings = settings::Settings::load(); diff --git a/server-cli/src/tui_runner.rs b/server-cli/src/tui_runner.rs index 2ad1cfa457..d54d48d689 100644 --- a/server-cli/src/tui_runner.rs +++ b/server-cli/src/tui_runner.rs @@ -1,4 +1,4 @@ -use crate::{cmd, logging::LOG, Message}; +use crate::{cmd, Message, LOG}; use crossterm::{ event::{DisableMouseCapture, EnableMouseCapture}, execute, diff --git a/voxygen/Cargo.toml b/voxygen/Cargo.toml index ed8979c9bb..b2a35af129 100644 --- a/voxygen/Cargo.toml +++ b/voxygen/Cargo.toml @@ -13,7 +13,7 @@ gl = ["gfx_device_gl", "gfx_gl"] hot-anim = ["anim/use-dyn-lib"] singleplayer = ["server"] simd = ["vek/platform_intrinsics"] -tracy = ["tracing-tracy", "common/tracy", "common-ecs/tracy", "common-net/tracy", "common-sys/tracy", "client/tracy"] +tracy = ["common/tracy", "common-ecs/tracy", "common-frontend/tracy", "common-net/tracy", "common-sys/tracy", "client/tracy"] plugins = ["client/plugins"] default = ["gl", "singleplayer", "native-dialog", "plugins", "simd"] @@ -23,6 +23,7 @@ client = {package = "veloren-client", path = "../client"} common = {package = "veloren-common", path = "../common"} common-base = {package = "veloren-common-base", path = "../common/base"} common-ecs = {package = "veloren-common-ecs", path = "../common/ecs"} +common-frontend = {package = "veloren-common-frontend", path = "../common/frontend"} common-net = {package = "veloren-common-net", path = "../common/net"} common-sys = {package = "veloren-common-sys", path = "../common/sys"} @@ -90,14 +91,7 @@ inline_tweak = "1.0.2" itertools = "0.10.0" # Tracy -tracing-tracy = { version = "0.6.0", optional = true } - -# Logging -termcolor = "1.1" tracing = "0.1" -tracing-appender = "0.1" -tracing-log = "0.1.1" -tracing-subscriber = {version = "0.2.3", default-features = false, features = ["env-filter", "fmt", "chrono", "ansi", "smallvec", "tracing-log"]} [target.'cfg(target_os = "macos")'.dependencies] dispatch = "0.1.4" diff --git a/voxygen/src/hud/mod.rs b/voxygen/src/hud/mod.rs index 00a71bb512..2360fed373 100644 --- a/voxygen/src/hud/mod.rs +++ b/voxygen/src/hud/mod.rs @@ -641,6 +641,8 @@ impl Show { self.settings(true) }, }; + #[cfg(not(feature = "singleplayer"))] + let _global_state = global_state; } // TODO: Add self updating key-bindings element @@ -683,6 +685,8 @@ impl Show { #[cfg(feature = "singleplayer")] global_state.pause(); } + #[cfg(not(feature = "singleplayer"))] + let _global_state = global_state; } fn open_setting_tab(&mut self, tab: SettingsTab) { diff --git a/voxygen/src/lib.rs b/voxygen/src/lib.rs index b80024afa5..335ea8bb73 100644 --- a/voxygen/src/lib.rs +++ b/voxygen/src/lib.rs @@ -14,7 +14,6 @@ pub mod error; pub mod hud; pub mod i18n; pub mod key_state; -pub mod logging; pub mod menu; pub mod mesh; pub mod profile; diff --git a/voxygen/src/main.rs b/voxygen/src/main.rs index c44e6ecd0a..c3641e63da 100644 --- a/voxygen/src/main.rs +++ b/voxygen/src/main.rs @@ -6,7 +6,6 @@ use veloren_voxygen::{ audio::AudioFrontend, i18n::{self, i18n_asset_key, Localization}, - logging, profile::Profile, run, settings::{get_fps, AudioOutput, Settings}, @@ -34,7 +33,8 @@ fn main() { } // Init logging and hold the guards. - let _guards = logging::init(&settings); + const LOG_FILENAME: &str = "voxygen.log"; + let _guards = common_frontend::init_stdout(Some((&settings.log.logs_path, LOG_FILENAME))); if let Some(path) = veloren_voxygen::settings::voxygen_data_dir().parent() { info!("Using userdata dir at: {}", path.display()); diff --git a/voxygen/src/menu/main/client_init.rs b/voxygen/src/menu/main/client_init.rs index dbbb06682b..7111b6467c 100644 --- a/voxygen/src/menu/main/client_init.rs +++ b/voxygen/src/menu/main/client_init.rs @@ -29,6 +29,7 @@ pub enum Msg { pub enum ClientConnArgs { Host(String), + #[allow(dead_code)] //singleplayer Resolved(ConnectionArgs), } diff --git a/voxygen/src/menu/main/mod.rs b/voxygen/src/menu/main/mod.rs index f6d147177d..47d014be4f 100644 --- a/voxygen/src/menu/main/mod.rs +++ b/voxygen/src/menu/main/mod.rs @@ -11,10 +11,9 @@ use crate::{ window::Event, Direction, GlobalState, PlayState, PlayStateResult, }; -use client::{ - addr::ConnectionArgs, - error::{InitProtocolError, NetworkConnectError, NetworkError}, -}; +#[cfg(feature = "singleplayer")] +use client::addr::ConnectionArgs; +use client::error::{InitProtocolError, NetworkConnectError, NetworkError}; use client_init::{ClientConnArgs, ClientInit, Error as InitError, Msg as InitMsg}; use common::{assets::AssetExt, comp}; use common_base::span;