mirror of
https://github.com/neocturne/MinedMap.git
synced 2025-07-01 05:29:05 +02:00
Use tracing for configurable logging
This commit is contained in:
parent
e57ec81d96
commit
a8eb2da95d
7 changed files with 164 additions and 11 deletions
|
@ -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
Add a link
Reference in a new issue