diff --git a/src/app.rs b/src/app.rs index c3e48a7..11c1929 100644 --- a/src/app.rs +++ b/src/app.rs @@ -73,7 +73,7 @@ impl EmApp { let mut path = self.home_path.clone(); path.push("export"); if !path.is_dir() { - println!("Creating {}", path.to_string_lossy()); + log::debug!("Creating export directory {}", path.to_string_lossy()); fs::create_dir_all(&path).expect("Create export directory."); } path.push( @@ -81,7 +81,7 @@ impl EmApp { .format("%Y-%m-%d_%H-%M-%S.mid") .to_string(), ); - println!("Saving to {}", path.to_string_lossy()); + log::info!("Saving to {}", path.to_string_lossy()); self.stave.save_to(&PathBuf::from(path)); } diff --git a/src/audio_setup.rs b/src/audio_setup.rs index f3ffec1..02ef5b1 100644 --- a/src/audio_setup.rs +++ b/src/audio_setup.rs @@ -22,19 +22,19 @@ pub fn midi_keyboard_input( ) -> Option> { let input = MidiInput::new("emmate").unwrap(); let mut port_idx = None; - println!("Available MIDI input ports:"); + log::debug!("Available MIDI input ports:"); let ports = input.ports(); for (i, port) in ports.iter().enumerate() { let name = input.port_name(&port).unwrap(); - println!("\t{}", name); + log::debug!("\t{}", name); if name.starts_with(name_prefix) { port_idx = Some(i); - println!("Selected MIDI input: '{}'", name); + log::info!("Selected MIDI input: '{}'", name); break; } } if port_idx == None { - println!("WARN No midi input selected."); + log::warn!("WARN No midi input selected."); return None; } let port = ports.get(port_idx.unwrap()).unwrap(); diff --git a/src/midi.rs b/src/midi.rs index cea30bd..d99b78e 100644 --- a/src/midi.rs +++ b/src/midi.rs @@ -19,8 +19,8 @@ pub struct SmfSource { pub fn load_smf(smf_data: &Vec) -> (Vec>, u32) { let smf = Smf::parse(smf_data).unwrap(); - println!("SMF header {:#?}", &smf.header); - println!( + log::debug!("SMF header {:#?}", &smf.header); + log::debug!( "SMF file has {} tracks, format is {:?}.", smf.tracks.len(), smf.header.format diff --git a/src/stave.rs b/src/stave.rs index e0490cc..8fc2be2 100644 --- a/src/stave.rs +++ b/src/stave.rs @@ -401,7 +401,7 @@ impl Stave { if !(note_a.is_some() || note_b.is_some() || cc_a.is_some() || cc_b.is_some()) { // TODO (implementation) Handle bookmarks (can be either animated somehow or just ignored). - print!("WARN No animation params (a bookmark?)."); + log::trace!("No animation params (a bookmark?)."); } } } @@ -822,7 +822,7 @@ impl Stave { if let Some(time) = time { self.time_selection = Some(*time..*time); } - } else if response.drag_released_by(drag_button) { + } else if response.drag_stopped_by(drag_button) { // Just documenting how it can be handled } else if response.dragged_by(drag_button) { if let Some(time) = time { @@ -854,7 +854,7 @@ impl Stave { }); } } - } else if response.drag_released_by(drag_button) { + } else if response.drag_stopped_by(drag_button) { if let Some(draw) = &self.note_draw.clone() { if !draw.time.is_empty() { let time_range = (draw.time.start, draw.time.end); diff --git a/src/track.rs b/src/track.rs index 65b5b28..511194e 100644 --- a/src/track.rs +++ b/src/track.rs @@ -206,7 +206,7 @@ pub fn from_midi_events( }), }); } - None => eprintln!("INFO NoteOff event without NoteOn {:?}", ev), + None => log::warn!("NoteOff event without NoteOn {:?}", ev), _ => panic!("ERROR Unexpected state: {:?} event in \"on\" queue.", on), } } @@ -218,7 +218,7 @@ pub fn from_midi_events( value: value.into(), }), }), - _ => eprintln!("DEBUG Event ignored {:?}", ev), + _ => log::trace!("Event ignored {:?}", ev), }, _ => (), }; diff --git a/src/track_history.rs b/src/track_history.rs index ba90b65..8b7b17a 100644 --- a/src/track_history.rs +++ b/src/track_history.rs @@ -71,7 +71,7 @@ impl TrackHistory { fn update(&mut self, applied_command: &(EditCommandId, Vec)) { let (command_id, diff) = applied_command; if diff.is_empty() { - dbg!("No changes."); + log::trace!("No changes."); return; } // The changeset should be already applied to track by now. @@ -109,14 +109,18 @@ impl TrackHistory { let version = self.get_version(version_id); assert_eq!(version.id, version_id); if version.is_empty() { - println!("No track history found."); + log::info!("No track history found."); return false; } { let track = self.track.clone(); track.edit(|track| self.apply_patches(changes, version, track)); } - dbg!(self.version, version_id); + log::debug!( + "Actual version {}, required version {}", + self.version, + version_id + ); self.write_meta(); self.version == version_id } @@ -134,7 +138,7 @@ impl TrackHistory { if let Some(snapshot_path) = version.snapshot_path { track.reset(util::load(&snapshot_path)); self.set_version(version.id); - println!("Found a snapshot for revision {}.", version.id); + log::debug!("Found a snapshot for revision {}.", version.id); } // Replays while self.version < version.id { @@ -216,7 +220,7 @@ impl TrackHistory { } pub fn with_directory(directory: &PathBuf) -> Self { - dbg!("history directory", directory.to_string_lossy()); + log::info!("History directory {}", directory.to_string_lossy()); Self { directory: directory.to_owned(), id_seq: Arc::new(IdSeq::new(0)),