mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
fix server-cli tracing accepting RUST_LOG env var and pass RUST_LOG via docker-compose rather than hardcoding it
- however RUST_BACKTRACE=1 is still hardcoded as its probably useful - dont spam the server-cli with debug
This commit is contained in:
parent
807df57f64
commit
c558c9de7c
@ -13,4 +13,4 @@ server = { package = "veloren-server", path = "../server", default-features = fa
|
|||||||
common = { package = "veloren-common", path = "../common" }
|
common = { package = "veloren-common", path = "../common" }
|
||||||
|
|
||||||
tracing = { version = "0.1", default-features = false }
|
tracing = { version = "0.1", default-features = false }
|
||||||
tracing-subscriber = { version = "0.2.3", default-features = false, features = ["fmt", "chrono", "ansi", "smallvec"] }
|
tracing-subscriber = { version = "0.2.3", default-features = false, features = ["env-filter", "fmt", "chrono", "ansi", "smallvec"] }
|
||||||
|
@ -13,4 +13,4 @@ COPY ./assets/common /opt/assets/common
|
|||||||
COPY ./assets/world /opt/assets/world
|
COPY ./assets/world /opt/assets/world
|
||||||
|
|
||||||
WORKDIR /opt
|
WORKDIR /opt
|
||||||
CMD [ "sh", "-c", "RUST_LOG=info,common=debug,common::net=info RUST_BACKTRACE=1 /opt/veloren-server-cli" ]
|
CMD [ "sh", "-c", "RUST_BACKTRACE=1 /opt/veloren-server-cli" ]
|
||||||
|
@ -10,6 +10,8 @@ services:
|
|||||||
restart: on-failure:0
|
restart: on-failure:0
|
||||||
volumes:
|
volumes:
|
||||||
- "./saves:/opt/saves"
|
- "./saves:/opt/saves"
|
||||||
|
environment:
|
||||||
|
- RUST_LOG=debug,common::net=info
|
||||||
watchtower:
|
watchtower:
|
||||||
image: containrrr/watchtower
|
image: containrrr/watchtower
|
||||||
volumes:
|
volumes:
|
||||||
|
@ -4,18 +4,38 @@
|
|||||||
use common::clock::Clock;
|
use common::clock::Clock;
|
||||||
use server::{Event, Input, Server, ServerSettings};
|
use server::{Event, Input, Server, ServerSettings};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use tracing::info;
|
use tracing::{info, Level};
|
||||||
|
use tracing_subscriber::{filter::LevelFilter, EnvFilter, FmtSubscriber};
|
||||||
|
|
||||||
const TPS: u64 = 30;
|
const TPS: u64 = 30;
|
||||||
|
const RUST_LOG_ENV: &str = "RUST_LOG";
|
||||||
|
|
||||||
#[allow(clippy::redundant_pattern_matching)] // TODO: Pending review in #587
|
#[allow(clippy::redundant_pattern_matching)] // TODO: Pending review in #587
|
||||||
fn main() {
|
fn main() {
|
||||||
// Init logging
|
// Init logging
|
||||||
if let Err(_) = std::env::var("RUST_LOG") {
|
let filter = match std::env::var_os(RUST_LOG_ENV).map(|s| s.into_string()) {
|
||||||
std::env::set_var("RUST_LOG", "info");
|
Some(Ok(env)) => {
|
||||||
|
let mut filter = EnvFilter::new("veloren_world::sim=info")
|
||||||
|
.add_directive("veloren_world::civ=info".parse().unwrap())
|
||||||
|
.add_directive(LevelFilter::INFO.into());
|
||||||
|
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
|
||||||
|
},
|
||||||
|
_ => EnvFilter::from_env(RUST_LOG_ENV)
|
||||||
|
.add_directive("veloren_world::sim=info".parse().unwrap())
|
||||||
|
.add_directive("veloren_world::civ=info".parse().unwrap())
|
||||||
|
.add_directive(LevelFilter::INFO.into()),
|
||||||
|
};
|
||||||
|
|
||||||
tracing_subscriber::fmt::init();
|
FmtSubscriber::builder()
|
||||||
|
.with_max_level(Level::ERROR)
|
||||||
|
.with_env_filter(filter)
|
||||||
|
.init();
|
||||||
|
|
||||||
info!("Starting server...");
|
info!("Starting server...");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user