Use log / stderrlog
This commit is contained in:
		
							parent
							
								
									e040ef14ff
								
							
						
					
					
						commit
						bb6bc07906
					
				| @ -4,13 +4,14 @@ version = "0.1.0" | ||||
| authors = ["Thomas Forgione <thomas@tforgione.fr>"] | ||||
| 
 | ||||
| [dependencies] | ||||
| log = "0.4" | ||||
| stderrlog = "0.4.1" | ||||
| num = "0.1.42" | ||||
| glium = "0.22.0" | ||||
| image = "0.19.0" | ||||
| byteorder = "1.2.3" | ||||
| clap = "2.31.2" | ||||
| nalgebra = "0.15.3" | ||||
| verbose-log = { git = "https://gitea.tforgione.fr/dash-3d/verbose-log" } | ||||
| 
 | ||||
| [[bin]] | ||||
| name = "3d-viewer" | ||||
|  | ||||
| @ -2,11 +2,14 @@ | ||||
| 
 | ||||
| #![warn(missing_docs)] | ||||
| 
 | ||||
| #[macro_use] | ||||
| extern crate log; | ||||
| extern crate stderrlog; | ||||
| 
 | ||||
| extern crate num; | ||||
| extern crate image; | ||||
| extern crate nalgebra; | ||||
| 
 | ||||
| #[macro_use] extern crate verbose_log; | ||||
| #[macro_use] extern crate glium; | ||||
| 
 | ||||
| pub mod math; | ||||
|  | ||||
| @ -145,7 +145,7 @@ impl Model { | ||||
|         for (name, material) in &other.materials { | ||||
|             let entry = self.materials.entry(name.clone()); | ||||
|             if let Entry::Occupied(_) = entry { | ||||
|                 eprintln!("Warning: materials merged but sharing the same name"); | ||||
|                 warn!("Materials merged but sharing the same name"); | ||||
|                 // Return error
 | ||||
|             } else { | ||||
|                 entry.or_insert(material.clone()); | ||||
| @ -156,7 +156,7 @@ impl Model { | ||||
|         for (name, texture) in &other.textures { | ||||
|             let entry = self.textures.entry(name.clone()); | ||||
|             if let Entry::Occupied(_) = entry { | ||||
|                 eprintln!("Warning: textures merged but sharing the same name"); | ||||
|                 warn!("Textures merged but sharing the same name"); | ||||
|                 // return Error;
 | ||||
|             } else { | ||||
|                 entry.or_insert(texture.clone()); | ||||
| @ -172,7 +172,7 @@ impl Model { | ||||
|         for (name, material) in other.materials { | ||||
|             let entry = self.materials.entry(name); | ||||
|             if let Entry::Occupied(_) = entry { | ||||
|                 eprintln!("Warning: materials merged but sharing the same name"); | ||||
|                 warn!("Materials merged but sharing the same name"); | ||||
|                 // Return error
 | ||||
|             } else { | ||||
|                 entry.or_insert(material); | ||||
| @ -183,7 +183,7 @@ impl Model { | ||||
|         for (name, texture) in other.textures { | ||||
|             let entry = self.textures.entry(name); | ||||
|             if let Entry::Occupied(_) = entry { | ||||
|                 eprintln!("Warning: textures merged but sharing the same name"); | ||||
|                 warn!("Textures merged but sharing the same name"); | ||||
|                 // return Error;
 | ||||
|             } else { | ||||
|                 entry.or_insert(texture); | ||||
| @ -235,7 +235,7 @@ impl Model { | ||||
|         for (name, material) in other.materials { | ||||
|             let entry = self.materials.entry(name); | ||||
|             if let Entry::Occupied(_) = entry { | ||||
|                 eprintln!("Warning: materials merged but sharing the same name"); | ||||
|                 warn!("Materials merged but sharing the same name"); | ||||
|                 // Return error
 | ||||
|             } else { | ||||
|                 entry.or_insert(material); | ||||
| @ -246,7 +246,7 @@ impl Model { | ||||
|         for (name, texture) in other.textures { | ||||
|             let entry = self.textures.entry(name); | ||||
|             if let Entry::Occupied(_) = entry { | ||||
|                 eprintln!("Warning: textures merged but sharing the same name"); | ||||
|                 warn!("Textures merged but sharing the same name"); | ||||
|                 // return Error;
 | ||||
|             } else { | ||||
|                 entry.or_insert(texture); | ||||
|  | ||||
| @ -204,7 +204,7 @@ pub trait Parser { | ||||
| 
 | ||||
|     /// Parses a file and adds its content to an already existing model.
 | ||||
|     fn parse_into_model<R: Read>(&mut self, model: &mut Model, reader: R, path: &str) -> Result<(), ParserError> { | ||||
|         logln!("Parsing {}...", path); | ||||
|         info!("Parsing {}...", path); | ||||
|         self.priv_parse_into_model(model, reader, path) | ||||
|     } | ||||
| 
 | ||||
|  | ||||
| @ -82,7 +82,7 @@ impl ObjParser { | ||||
|             ))) | ||||
|         } else { | ||||
|             let values = parse_values(line_number, line, path, 3)?; | ||||
|             logln!("Warning: expected 2 coordinates, but received 3, ignoring the last one..."); | ||||
|             warn!("Warning: expected 2 coordinates, but received 3, ignoring the last one..."); | ||||
|             Ok(Element::TextureCoordinate(Vector2::<f64>::new( | ||||
|                 values[0], | ||||
|                 values[1], | ||||
|  | ||||
| @ -1,7 +1,8 @@ | ||||
| #[macro_use] | ||||
| extern crate log; | ||||
| extern crate stderrlog; | ||||
| extern crate clap; | ||||
| extern crate glium; | ||||
| #[macro_use] | ||||
| extern crate verbose_log; | ||||
| extern crate model_converter; | ||||
| 
 | ||||
| use std::process::exit; | ||||
| @ -52,11 +53,16 @@ fn main() { | ||||
|         .arg(Arg::with_name("verbose") | ||||
|              .short("v") | ||||
|              .long("verbose") | ||||
|              .multiple(true) | ||||
|              .help("Shows logs during the parsing of the model")) | ||||
|         .get_matches(); | ||||
| 
 | ||||
|     // Set verbose flag
 | ||||
|     verbose_log::set(matches.occurrences_of("verbose") > 0); | ||||
|     stderrlog::new() | ||||
|         .module(module_path!()) | ||||
|         .verbosity(matches.occurrences_of("verbose") as usize) | ||||
|         .init() | ||||
|         .expect("Couldn't initialize logger"); | ||||
| 
 | ||||
|     let mut capture_count = 0; | ||||
| 
 | ||||
| @ -69,6 +75,9 @@ fn main() { | ||||
|     let mut models = vec![]; | ||||
| 
 | ||||
|     for input in matches.values_of("input").unwrap() { | ||||
| 
 | ||||
|         info!("Parsing model {}", input); | ||||
| 
 | ||||
|         match parse_file(&input) { | ||||
|             Ok(model) => { | ||||
|                 if model.vertices.len() > 0 { | ||||
| @ -77,7 +86,7 @@ fn main() { | ||||
|                 models.push((input.to_owned(), model)) | ||||
|             }, | ||||
|             Err(e) => { | ||||
|                 eprintln!("Error while parsing file: {}", e); | ||||
|                 error!("Error while parsing file: {}", e); | ||||
|                 exit(1); | ||||
|             }, | ||||
|         } | ||||
| @ -95,24 +104,25 @@ fn main() { | ||||
|     let mut duration; | ||||
| 
 | ||||
|     for (name, mut model) in models { | ||||
|         log!("Scaling model {}...", name); | ||||
|         info!("Scaling model {}...", name); | ||||
|         model.center_and_scale_from_box(&bbox); | ||||
| 
 | ||||
|         log!("\nBuilding textures for model {}...", name); | ||||
|         info!("Building textures for model {}...", name); | ||||
| 
 | ||||
|         before = Instant::now(); | ||||
|         model.build_textures(&renderer); | ||||
|         duration = Instant::now().duration_since(before); | ||||
| 
 | ||||
|         log!(" done in {}ms.\nBuilding vertex buffers for model {}...", | ||||
|              as_millis(duration) ,name); | ||||
|         info!("Done in {}ms.", as_millis(duration)); | ||||
|         info!("Building vertex buffers for model {}...", name); | ||||
| 
 | ||||
|         before = Instant::now(); | ||||
|         model.build_vertex_buffers(&renderer); | ||||
|         duration = Instant::now().duration_since(before); | ||||
| 
 | ||||
|         scene.emplace(model); | ||||
|         logln!(" done in {}ms.\nFinished", as_millis(duration)); | ||||
|         info!("Done in {}ms.", as_millis(duration)); | ||||
|         info!("Finished"); | ||||
|     } | ||||
| 
 | ||||
|     let mut closed = false; | ||||
| @ -174,13 +184,13 @@ fn main() { | ||||
|                         }, .. | ||||
|                     }, .. | ||||
|                 } => { | ||||
|                     println!("Camera:"); | ||||
|                     trace!("Camera:"); | ||||
| 
 | ||||
|                     println!("\tPosition: ({}, {}, {})", | ||||
|                     trace!("\tPosition: ({}, {}, {})", | ||||
|                         camera.position.x(), camera.position.y(), camera.position.z()); | ||||
|                     println!("\tTarget:   ({}, {}, {})", | ||||
|                     trace!("\tTarget:   ({}, {}, {})", | ||||
|                         camera.target.x(), camera.target.y(), camera.target.z()); | ||||
|                     println!("\tUp:       ({}, {}, {})", | ||||
|                     trace!("\tUp:       ({}, {}, {})", | ||||
|                         camera.up.x(), camera.up.y(), camera.up.z()); | ||||
|                 }, | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user