mirror of
https://github.com/neocturne/MinedMap.git
synced 2025-03-04 17:23:33 +01:00
Use tracing for configurable logging
This commit is contained in:
parent
e57ec81d96
commit
a8eb2da95d
7 changed files with 164 additions and 11 deletions
135
Cargo.lock
generated
135
Cargo.lock
generated
|
@ -478,6 +478,12 @@ dependencies = [
|
|||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.148"
|
||||
|
@ -504,6 +510,12 @@ dependencies = [
|
|||
"scopeguard",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
|
||||
|
||||
[[package]]
|
||||
name = "lru"
|
||||
version = "0.11.1"
|
||||
|
@ -552,6 +564,8 @@ dependencies = [
|
|||
"serde",
|
||||
"serde_json",
|
||||
"tokio",
|
||||
"tracing",
|
||||
"tracing-subscriber",
|
||||
"zstd",
|
||||
]
|
||||
|
||||
|
@ -595,6 +609,16 @@ dependencies = [
|
|||
"simd-adler32",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nu-ansi-term"
|
||||
version = "0.46.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84"
|
||||
dependencies = [
|
||||
"overload",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-integer"
|
||||
version = "0.1.45"
|
||||
|
@ -650,6 +674,12 @@ version = "1.18.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d"
|
||||
|
||||
[[package]]
|
||||
name = "overload"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39"
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot"
|
||||
version = "0.12.1"
|
||||
|
@ -823,6 +853,15 @@ dependencies = [
|
|||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sharded-slab"
|
||||
version = "0.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "simd-adler32"
|
||||
version = "0.3.7"
|
||||
|
@ -872,6 +911,16 @@ dependencies = [
|
|||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thread_local"
|
||||
version = "1.1.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio"
|
||||
version = "1.32.0"
|
||||
|
@ -883,6 +932,64 @@ dependencies = [
|
|||
"pin-project-lite",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing"
|
||||
version = "0.1.37"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"pin-project-lite",
|
||||
"tracing-attributes",
|
||||
"tracing-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-attributes"
|
||||
version = "0.1.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.36",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-core"
|
||||
version = "0.1.31"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
"valuable",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-log"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"log",
|
||||
"tracing-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-subscriber"
|
||||
version = "0.3.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "30a651bc37f915e81f087d86e62a18eec5f79550c7faff886f7090b4ea757c77"
|
||||
dependencies = [
|
||||
"nu-ansi-term",
|
||||
"sharded-slab",
|
||||
"smallvec",
|
||||
"thread_local",
|
||||
"tracing-core",
|
||||
"tracing-log",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.12"
|
||||
|
@ -895,12 +1002,40 @@ version = "0.2.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
|
||||
|
||||
[[package]]
|
||||
name = "valuable"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d"
|
||||
|
||||
[[package]]
|
||||
name = "version_check"
|
||||
version = "0.9.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
|
||||
dependencies = [
|
||||
"winapi-i686-pc-windows-gnu",
|
||||
"winapi-x86_64-pc-windows-gnu",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.48.0"
|
||||
|
|
|
@ -43,6 +43,8 @@ rustc-hash = "1.1.0"
|
|||
serde = { version = "1.0.152", features = ["rc", "derive"] }
|
||||
serde_json = "1.0.99"
|
||||
tokio = { version = "1.31.0", features = ["rt", "parking_lot", "sync"] }
|
||||
tracing = "0.1.37"
|
||||
tracing-subscriber = "0.3.17"
|
||||
zstd = "0.12.3"
|
||||
|
||||
[features]
|
||||
|
|
|
@ -35,6 +35,9 @@ pub struct Args {
|
|||
/// use one thread per logical CPU core.
|
||||
#[arg(short, long)]
|
||||
pub jobs: Option<usize>,
|
||||
/// Enable verbose messages
|
||||
#[arg(short, long)]
|
||||
pub verbose: bool,
|
||||
/// Minecraft save directory
|
||||
pub input_dir: PathBuf,
|
||||
/// MinedMap data directory
|
||||
|
@ -54,6 +57,15 @@ pub fn cli() -> Result<()> {
|
|||
let args = Args::parse();
|
||||
let config = Config::new(&args);
|
||||
|
||||
tracing_subscriber::fmt()
|
||||
.with_max_level(if args.verbose {
|
||||
tracing::Level::DEBUG
|
||||
} else {
|
||||
tracing::Level::INFO
|
||||
})
|
||||
.with_target(false)
|
||||
.init();
|
||||
|
||||
setup_threads(config.num_threads)?;
|
||||
|
||||
let rt = tokio::runtime::Builder::new_current_thread()
|
||||
|
|
|
@ -5,6 +5,7 @@ use std::{ffi::OsStr, path::Path, time::SystemTime};
|
|||
use anyhow::{Context, Result};
|
||||
use indexmap::IndexSet;
|
||||
use rayon::prelude::*;
|
||||
use tracing::{debug, error};
|
||||
|
||||
use super::common::*;
|
||||
use crate::{
|
||||
|
@ -148,11 +149,11 @@ impl<'a> RegionProcessor<'a> {
|
|||
|
||||
if Some(input_timestamp) <= output_timestamp && Some(input_timestamp) <= lightmap_timestamp
|
||||
{
|
||||
println!("Skipping unchanged region r.{}.{}.mca", coords.x, coords.z);
|
||||
debug!("Skipping unchanged region r.{}.{}.mca", coords.x, coords.z);
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
println!("Processing region r.{}.{}.mca", coords.x, coords.z);
|
||||
debug!("Processing region r.{}.{}.mca", coords.x, coords.z);
|
||||
|
||||
crate::nbt::region::from_file(path)?.foreach_chunk(
|
||||
|chunk_coords, data: world::de::Chunk| {
|
||||
|
@ -204,7 +205,7 @@ impl<'a> RegionProcessor<'a> {
|
|||
|
||||
regions.par_iter().for_each(|&coords| {
|
||||
if let Err(err) = self.process_region(coords) {
|
||||
eprintln!("Failed to process region {:?}: {:?}", coords, err);
|
||||
error!("Failed to process region {:?}: {:?}", coords, err);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
use anyhow::{Context, Result};
|
||||
use rayon::prelude::*;
|
||||
use tracing::{debug, warn};
|
||||
|
||||
use super::common::*;
|
||||
use crate::{io::fs, types::*};
|
||||
|
@ -83,7 +84,7 @@ impl<'a> TileMipmapper<'a> {
|
|||
let timestamp = match fs::modified_timestamp(&source_path) {
|
||||
Ok(timestamp) => timestamp,
|
||||
Err(err) => {
|
||||
eprintln!("{}", err);
|
||||
warn!("{}", err);
|
||||
return None;
|
||||
}
|
||||
};
|
||||
|
@ -96,7 +97,7 @@ impl<'a> TileMipmapper<'a> {
|
|||
};
|
||||
|
||||
if Some(input_timestamp) <= output_timestamp {
|
||||
println!(
|
||||
debug!(
|
||||
"Skipping unchanged mipmap tile {}",
|
||||
output_path
|
||||
.strip_prefix(&self.config.output_dir)
|
||||
|
@ -106,7 +107,7 @@ impl<'a> TileMipmapper<'a> {
|
|||
return Ok(());
|
||||
}
|
||||
|
||||
println!(
|
||||
debug!(
|
||||
"Rendering mipmap tile {}",
|
||||
output_path
|
||||
.strip_prefix(&self.config.output_dir)
|
||||
|
@ -121,7 +122,7 @@ impl<'a> TileMipmapper<'a> {
|
|||
let source = match image::open(&source_path) {
|
||||
Ok(source) => source,
|
||||
Err(err) => {
|
||||
eprintln!(
|
||||
warn!(
|
||||
"Failed to read source image {}: {}",
|
||||
source_path.display(),
|
||||
err,
|
||||
|
|
|
@ -12,6 +12,7 @@ use glam::Vec3;
|
|||
use lru::LruCache;
|
||||
use rayon::prelude::*;
|
||||
use tokio::sync::OnceCell;
|
||||
use tracing::debug;
|
||||
|
||||
use super::{common::*, region_group::RegionGroup};
|
||||
use crate::{
|
||||
|
@ -272,7 +273,7 @@ impl<'a> TileRenderer<'a> {
|
|||
let output_timestamp = fs::read_timestamp(&output_path, FILE_META_VERSION);
|
||||
|
||||
if Some(processed_timestamp) <= output_timestamp {
|
||||
println!(
|
||||
debug!(
|
||||
"Skipping unchanged tile {}",
|
||||
output_path
|
||||
.strip_prefix(&self.config.output_dir)
|
||||
|
@ -282,7 +283,7 @@ impl<'a> TileRenderer<'a> {
|
|||
return Ok(());
|
||||
}
|
||||
|
||||
println!(
|
||||
debug!(
|
||||
"Rendering tile {}",
|
||||
output_path
|
||||
.strip_prefix(&self.config.output_dir)
|
||||
|
|
|
@ -7,6 +7,7 @@ use std::fmt::Debug;
|
|||
|
||||
use anyhow::{bail, Context, Result};
|
||||
use num_integer::div_rem;
|
||||
use tracing::warn;
|
||||
|
||||
use super::de;
|
||||
use crate::{
|
||||
|
@ -94,7 +95,7 @@ impl<'a> SectionV1_13<'a> {
|
|||
.map(|entry| {
|
||||
let block_type = block_types.get(&entry.name);
|
||||
if block_type.is_none() {
|
||||
eprintln!("Unknown block type: {}", entry.name);
|
||||
warn!("Unknown block type: {}", entry.name);
|
||||
}
|
||||
block_type
|
||||
})
|
||||
|
@ -246,7 +247,7 @@ impl<'a> BiomesV1_18<'a> {
|
|||
.map(|entry| {
|
||||
let biome_type = biome_types.get(entry);
|
||||
if biome_type.is_none() {
|
||||
eprintln!("Unknown biome type: {}", entry);
|
||||
warn!("Unknown biome type: {}", entry);
|
||||
}
|
||||
biome_type
|
||||
})
|
||||
|
|
Loading…
Add table
Reference in a new issue