Skip to content

Commit

Permalink
Very simple logging... (closes #10)
Browse files Browse the repository at this point in the history
  • Loading branch information
LaineZ committed May 16, 2020
1 parent a8b0e32 commit d0064f5
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 4 deletions.
24 changes: 24 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ minimp3 = "0.3.5"
crossterm = "0.17.4"
parking_lot = "0.10"
webbrowser = "0.5.2"
log = "0.4.8"
simple-logging = "2.0.2"
[dependencies.cpal]
git = "https://github.com/RustAudio/cpal.git"
rev = "fe22704d4adc2795f33f2e298c5450ece476d58c"
2 changes: 2 additions & 0 deletions bcrs.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[00:00:00.000] (b9c) INFO BandcampOnlinePlayer by 140bpmdubstep version 0.3alpha.rs Command line: ["target\\debug\\bandcamp-online-cli.exe"]
[00:00:01.401] (a1c) INFO Creating stream on Speakers (Realtek(R) Audio) with 44100 sample rate
4 changes: 4 additions & 0 deletions src/bc_core/playback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use minimp3::Decoder;

use cpal::traits::{DeviceTrait, HostTrait, StreamTrait};
use cpal::{ChannelCount, SampleRate, Stream, StreamConfig, StreamError};
use log::{info, trace, warn, error};

struct TimeTracker {
started_at: Instant,
Expand Down Expand Up @@ -124,6 +125,8 @@ impl PlayerThread {
sample_rate: SampleRate(44100),
};

info!("Creating stream on {} with {} sample rate", device.name().unwrap_or("Device name not found".to_string()), config.sample_rate.0);

let cmd_tx1 = cmd_tx.clone();
let (data_tx, data_rx) = mpsc::channel::<Vec<i16>>();
let data_fn = move |output: &mut [i16], _: &_| {
Expand Down Expand Up @@ -272,6 +275,7 @@ impl PlayerThread {

Command::StreamError(e) => {
// TODO: Make stream error
error!("Playback stream error: {}", e);
}

Command::AddVolume(value) => {
Expand Down
11 changes: 7 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@ mod bop_interfaces;
mod model;

use std::env;
use log::LevelFilter;

use bc_core::tags;
use bop_interfaces::cli_advanced;
use log::{info, trace, warn};

fn main() -> Result<(), Box<dyn std::error::Error>> {
let args: Vec<String> = env::args().collect();

println!(
"BandcampOnlinePlayer by 140bpmdubstep version 0.3alpha.rs\nCommand line: {:?}",
args
);
simple_logging::log_to_file("bcrs.log", LevelFilter::Info)?;

println!("BandcampOnlinePlayer by 140bpmdubstep version 0.3alpha.rs");

info!("BandcampOnlinePlayer by 140bpmdubstep version 0.3alpha.rs Command line: {:?}", args);

if args.len() < 2 {
cli_advanced::loadinterface(args.clone())?;
Expand Down

0 comments on commit d0064f5

Please sign in to comment.