Skip to content

Commit

Permalink
use tracing crate for logging
Browse files Browse the repository at this point in the history
  • Loading branch information
bastibl committed Jul 9, 2024
1 parent d5bd64f commit f8fba06
Show file tree
Hide file tree
Showing 60 changed files with 85 additions and 110 deletions.
13 changes: 6 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,6 @@ futures-lite = "2.3"
futuredsp = { path = "crates/futuredsp", version = "0.0.6" }
futuresdr-macros = { path = "crates/macros", version = "0.0.6" }
futuresdr-types = { path = "crates/types", version = "0.0.11" }
# they broke additive features in 0.4.22
# https://github.com/rust-lang/log/issues/635
log = { version = "=0.4.21", features = ["std", "max_level_debug", "release_max_level_info"] }
num-complex = "0.4"
num-integer = "0.1"
num_cpus = "1.16"
Expand All @@ -97,19 +94,20 @@ slab = "0.4"
spin = "0.9"
serde = { version = "1.0", features = ["derive"] }
thiserror = "1.0"
tracing = { version = "0.1", features = ["log", "max_level_debug", "release_max_level_info"] }
web-time = { version = "1.1" }
wgpu = { version = "0.20", optional = true }

[target.'cfg(target_arch = "wasm32")'.dependencies]
console_log = "1.0"
cpal = { version = "0.15", optional = true, features = ['wasm-bindgen'] }
getrandom = { version = "0.2", features = ["js"] }
gloo-net = {version = "0.5", default-features = false, features = ["websocket", "json"]}
gloo-timers = { version = "0.3", features = ["futures"] }
js-sys = "0.3"
rodio = { version = "0.18", default-features = false, optional = true }
rodio = { version = "0.19", default-features = false, optional = true }
serde-wasm-bindgen = "0.6"
serde_json = "1.0"
tracing-wasm = "0.2"
wasm-bindgen = "0.2"
wasm-bindgen-futures = "0.4"

Expand All @@ -129,9 +127,10 @@ core_affinity = "0.8"
cpal = { version = "0.15", optional = true }
hound = {version = "3.5", optional = true }
libc = "0.2"
rodio = { version = "0.18", default-features = false, features = ["symphonia-all"], optional = true }
rodio = { version = "0.19", default-features = false, features = ["symphonia-all"], optional = true }
tokio = { version = "1", features = ["rt"] }
tower-http = { version = "0.5", features = ["add-extension", "cors", "fs"] }
tracing-subscriber = { version = "0.3", features = ["env-filter", "fmt"] }
vmcircbuffer = "0.0.10"
vulkano = { version = "0.34", optional = true }
vulkano-shaders = { version = "0.34", optional = true }
Expand All @@ -142,7 +141,7 @@ lttng-ust = { git = "https://github.com/sprt/lttng-ust-rs.git", version = "0.1.0
xilinx-dma = { version = "0.0.10", features = ["async"], optional = true }

[target.'cfg(target_os = "android")'.dependencies]
android_logger = "0.13"
android_logger = "0.14"

[target.'cfg(target_arch = "wasm32")'.dependencies.web-sys]
version = "0.3"
Expand Down
1 change: 0 additions & 1 deletion crates/prophecy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ description = "FutureSDR GUI"

[dependencies]
console_error_panic_hook = "0.1"
console_log = "1"
futures = "0.3"
futuresdr = { version = "0.0.37", path = "../../" }
futuresdr-types = { version = "0.0.11", path = "../types/" }
Expand Down
1 change: 0 additions & 1 deletion crates/prophecy/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,6 @@ pub fn Prophecy() -> impl IntoView {
}

pub fn main() {
_ = console_log::init_with_level(log::Level::Debug);
console_error_panic_hook::set_once();
mount_to_body(|| view! { <FlowgraphCanvas /> })
}
5 changes: 2 additions & 3 deletions examples/adsb/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ rtlsdr = ["futuresdr/rtlsdr"]
soapy = ["futuresdr/soapy"]

[dependencies]
adsb_deku = "0.7"
clap = { version = "4", features = ["derive"] }
futuresdr = { path = "../..", features = ["seify"] }
serde = { version = "1", features = ["derive"] }
serde_with = "3"
serde_json = "1"
env_logger = "0.11"
adsb_deku = "0.7"
serde_with = "3"
6 changes: 2 additions & 4 deletions examples/adsb/src/bin/listen_adsb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ use futuresdr::blocks::Apply;
use futuresdr::blocks::FileSource;
use futuresdr::blocks::FirBuilder;
use futuresdr::blocks::Throttle;
use futuresdr::log::{warn, LevelFilter};
use futuresdr::num_complex::Complex32;
use futuresdr::num_integer;
use futuresdr::runtime::Flowgraph;
use futuresdr::runtime::Runtime;
use futuresdr::tracing::warn;
use std::time::Duration;

#[derive(Parser, Debug)]
Expand Down Expand Up @@ -56,11 +56,9 @@ fn sample_rate_parser(sample_rate_str: &str) -> Result<f64, String> {
}

fn main() -> Result<()> {
let mut builder = env_logger::Builder::from_default_env();
builder.filter(None, LevelFilter::Info).init();

let args = Args::parse();
let mut fg = Flowgraph::new();
futuresdr::runtime::init();

let src = match args.file {
Some(f) => {
Expand Down
2 changes: 1 addition & 1 deletion examples/adsb/src/decoder.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::DemodPacket;
use adsb_deku::deku::DekuContainerRead;
use futuresdr::anyhow::{bail, Result};
use futuresdr::log::{debug, info, warn};
use futuresdr::macros::async_trait;
use futuresdr::macros::message_handler;
use futuresdr::runtime::Block;
Expand All @@ -13,6 +12,7 @@ use futuresdr::runtime::MessageIoBuilder;
use futuresdr::runtime::Pmt;
use futuresdr::runtime::StreamIoBuilder;
use futuresdr::runtime::WorkIo;
use futuresdr::tracing::{debug, info, warn};
use serde::Serialize;
use std::time::SystemTime;

Expand Down
2 changes: 1 addition & 1 deletion examples/adsb/src/tracker.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use futuresdr::anyhow::Result;
use futuresdr::async_io::Timer;
use futuresdr::log::{info, warn};
use futuresdr::macros::async_trait;
use futuresdr::macros::message_handler;
use futuresdr::runtime::Block;
Expand All @@ -13,6 +12,7 @@ use futuresdr::runtime::Pmt;
use futuresdr::runtime::StreamIo;
use futuresdr::runtime::StreamIoBuilder;
use futuresdr::runtime::WorkIo;
use futuresdr::tracing::{info, warn};
use std::cmp::Ordering;
use std::time::Duration;

Expand Down
2 changes: 1 addition & 1 deletion examples/android-hw/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ use futuresdr::blocks::Apply;
use futuresdr::blocks::Fft;
use futuresdr::blocks::WebsocketSinkBuilder;
use futuresdr::blocks::WebsocketSinkMode;
use futuresdr::log::info;
use futuresdr::num_complex::Complex32;
use futuresdr::runtime::Flowgraph;
use futuresdr::runtime::Runtime;
use futuresdr::tracing::info;

pub fn run_fg() -> Result<()> {
futuresdr::runtime::init();
Expand Down
2 changes: 1 addition & 1 deletion examples/android/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ use futuresdr::blocks::VectorSink;
use futuresdr::blocks::VectorSinkBuilder;
use futuresdr::blocks::VectorSource;
use futuresdr::blocks::VulkanBuilder;
use futuresdr::log::info;
use futuresdr::runtime::buffer::vulkan::Broker;
use futuresdr::runtime::buffer::vulkan::D2H;
use futuresdr::runtime::buffer::vulkan::H2D;
use futuresdr::runtime::Flowgraph;
use futuresdr::runtime::Runtime;
use futuresdr::tracing::info;

pub fn run_fg() -> Result<()> {
let mut fg = Flowgraph::new();
Expand Down
1 change: 0 additions & 1 deletion examples/cw/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@ clap = { version = "4", features = ["derive"] }

[target.'cfg(target_arch = "wasm32")'.dependencies]
console_error_panic_hook = "0.1"
console_log = "1"
leptos = { version = "0.6", features = ["csr", "nightly"] }
1 change: 0 additions & 1 deletion examples/cw/src/bin/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ mod foo {

pub fn main() -> Result<()> {
std::panic::set_hook(Box::new(console_error_panic_hook::hook));
console_log::init().expect("could not initialize logger");
mount_to_body(|| view! { <Gui /> });
Ok(())
}
Expand Down
6 changes: 1 addition & 5 deletions examples/egui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@ aaronia_http = ["futuresdr/aaronia_http"]
soapy = ["futuresdr/soapy"]

[dependencies]
eframe = "0.27"
env_logger = { version = "0.11", default-features = false, features = [
"auto-color",
"humantime",
] }
eframe = "0.28"
futuresdr = { path = "../..", features = ["seify"] }
futuresdr-remote = { path = "../../crates/remote/" }
tokio = { version = "1", features = ["full"] }
Expand Down
4 changes: 2 additions & 2 deletions examples/egui/src/bin/combined.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use futuresdr_egui::ChannelSink;
use futuresdr_egui::FFT_SIZE;

fn main() -> Result<(), eframe::Error> {
env_logger::init();
futuresdr::runtime::init();
let options = eframe::NativeOptions {
viewport: egui::ViewportBuilder::default().with_inner_size([900.0, 600.0]),
multisampling: 4,
Expand All @@ -33,7 +33,7 @@ fn main() -> Result<(), eframe::Error> {
eframe::run_native(
"FutureSDR + egui",
options,
Box::new(|cc| Box::new(MyApp::new(cc))),
Box::new(|cc| Ok(Box::new(MyApp::new(cc)))),
)
}

Expand Down
4 changes: 2 additions & 2 deletions examples/egui/src/bin/egui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use tungstenite::Message;
use futuresdr_egui::FFT_SIZE;

fn main() -> Result<(), eframe::Error> {
env_logger::init();
futuresdr::runtime::init();
let options = eframe::NativeOptions {
viewport: egui::ViewportBuilder::default().with_inner_size([900.0, 600.0]),
multisampling: 4,
Expand All @@ -31,7 +31,7 @@ fn main() -> Result<(), eframe::Error> {
eframe::run_native(
"FutureSDR + egui",
options,
Box::new(|cc| Box::new(MyApp::new(cc))),
Box::new(|cc| Ok(Box::new(MyApp::new(cc)))),
)
}

Expand Down
2 changes: 1 addition & 1 deletion examples/keyfob/src/decoder.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use futuresdr::anyhow::Result;
use futuresdr::log::info;
use futuresdr::macros::async_trait;
use futuresdr::runtime::Block;
use futuresdr::runtime::BlockMeta;
Expand All @@ -10,6 +9,7 @@ use futuresdr::runtime::MessageIoBuilder;
use futuresdr::runtime::StreamIo;
use futuresdr::runtime::StreamIoBuilder;
use futuresdr::runtime::WorkIo;
use futuresdr::tracing::info;

#[derive(Debug)]
enum State {
Expand Down
2 changes: 1 addition & 1 deletion examples/logging/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2021"

[dependencies]
futuresdr = { path = "../.." }
env_logger = "0.11"
tracing-subscriber = { version = "0.3", features = ["fmt", "env-filter"] }

[[bin]]
name = "logging"
Expand Down
26 changes: 19 additions & 7 deletions examples/logging/logging.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
use env_logger::Builder;
use std::time;

use futuresdr::anyhow::Result;
use futuresdr::blocks::MessageSourceBuilder;
use futuresdr::log::info;
use futuresdr::log::LevelFilter;
use futuresdr::runtime::Flowgraph;
use futuresdr::runtime::Pmt;
use futuresdr::runtime::Runtime;
use futuresdr::tracing::info;
use futuresdr::tracing::level_filters::LevelFilter;
use std::time;
use tracing_subscriber::filter::EnvFilter;
use tracing_subscriber::fmt;
use tracing_subscriber::prelude::*;

fn main() -> Result<()> {
let mut builder = Builder::from_default_env();
builder.filter(None, LevelFilter::Info).init();
let format = fmt::layer()
.with_level(true)
.with_target(true)
.with_thread_ids(true)
.with_thread_names(true)
.compact();

let filter = EnvFilter::from_env("FOO_LOG").add_directive(LevelFilter::DEBUG.into());

tracing_subscriber::registry()
.with(filter)
.with(format)
.init();

let mut fg = Flowgraph::new();

Expand Down
1 change: 0 additions & 1 deletion examples/rattlegram/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ hound = "3.5"

[target.'cfg(target_arch = "wasm32")'.dependencies]
console_error_panic_hook = "0.1"
console_log = "1"
gloo-timers = { version = "0.3", features = ["futures"] }
leptos = { version = "0.6", features = ["csr", "nightly"] }
wasm-bindgen-futures = "0.4"
Expand Down
2 changes: 1 addition & 1 deletion examples/rattlegram/src/decoder.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use futuresdr::anyhow::Result;
use futuresdr::log::info;
use futuresdr::macros::async_trait;
use futuresdr::num_complex::Complex32;
use futuresdr::runtime::Block;
Expand All @@ -11,6 +10,7 @@ use futuresdr::runtime::MessageIoBuilder;
use futuresdr::runtime::StreamIo;
use futuresdr::runtime::StreamIoBuilder;
use futuresdr::runtime::WorkIo;
use futuresdr::tracing::info;
use rustfft::Fft;
use rustfft::FftPlanner;
use std::sync::Arc;
Expand Down
3 changes: 1 addition & 2 deletions examples/rattlegram/src/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ use futuresdr::anyhow::Result;
use futuresdr::blocks::audio::AudioSink;
use futuresdr::blocks::ChannelSource;
use futuresdr::futures::channel::mpsc;
use futuresdr::log::warn;
use futuresdr::macros::connect;
use futuresdr::runtime::Flowgraph;
use futuresdr::runtime::Runtime;
use futuresdr::tracing::warn;
use gloo_timers::future::TimeoutFuture;
use leptos::html::Input;
use leptos::*;
Expand All @@ -21,7 +21,6 @@ extern "C" {
}

pub fn wasm_main() {
_ = console_log::init_with_level(futuresdr::log::Level::Debug);
console_error_panic_hook::set_once();
mount_to_body(|| view! { <Gui /> })
}
Expand Down
3 changes: 1 addition & 2 deletions examples/rattlegram/src/wasm_decoder.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use futuresdr::log::info;
use futuresdr::tracing::info;
use web_sys::wasm_bindgen;
use web_sys::wasm_bindgen::prelude::*;

Expand All @@ -25,7 +25,6 @@ pub enum DecoderMessage {
#[wasm_bindgen]
impl WasmDecoder {
pub fn new() -> Self {
_ = console_log::init_with_level(futuresdr::log::Level::Debug);
console_error_panic_hook::set_once();
Self {
samples: Vec::new(),
Expand Down
1 change: 0 additions & 1 deletion examples/spectrum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ wasm-bindgen-futures = "0.4"

[target.'cfg(target_arch = "wasm32")'.dependencies]
console_error_panic_hook = "0.1"
console_log = "1"
gloo-net = "0.5"
leptos = { version = "0.6", features = ["csr", "nightly"] }
log = "0.4"
Expand Down
2 changes: 1 addition & 1 deletion examples/spectrum/src/vulkan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use vulkano::pipeline::PipelineBindPoint;
use vulkano::sync::{self, GpuFuture};

use futuresdr::anyhow::{Context, Result};
use futuresdr::log::debug;
use futuresdr::macros::async_trait;
use futuresdr::runtime::buffer::vulkan::Broker;
use futuresdr::runtime::buffer::vulkan::BufferEmpty;
Expand All @@ -31,6 +30,7 @@ use futuresdr::runtime::MessageIoBuilder;
use futuresdr::runtime::StreamIo;
use futuresdr::runtime::StreamIoBuilder;
use futuresdr::runtime::WorkIo;
use futuresdr::tracing::debug;

#[allow(clippy::needless_question_mark)]
#[allow(deprecated)]
Expand Down
1 change: 0 additions & 1 deletion examples/spectrum/src/wasm/frontend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ pub fn Gui() -> impl IntoView {
}

pub fn frontend() {
_ = console_log::init_with_level(log::Level::Debug);
console_error_panic_hook::set_once();
mount_to_body(|| view! { <Gui /> })
}
1 change: 0 additions & 1 deletion examples/spectrum/src/wasm/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ pub fn Gui() -> impl IntoView {
}

pub fn web() {
_ = console_log::init_with_level(log::Level::Debug);
console_error_panic_hook::set_once();
mount_to_body(|| view! { <Gui /> })
}
Expand Down
1 change: 0 additions & 1 deletion examples/wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ rand = "0.8"

[target.'cfg(target_arch = "wasm32")'.dependencies]
console_error_panic_hook = "0.1"
console_log = { version = "1.0", features = ["color"] }
getrandom = { version = "0.2", features = ["js"] }
wasm-bindgen-futures = "0.4"

Loading

0 comments on commit f8fba06

Please sign in to comment.