Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ fn main() -> Result<(), PlatformError> {
let main_window = WindowDesc::new(ui_builder());
let data = 0_u32;
AppLauncher::with_window(main_window)
.use_env_tracing()
.log_to_console()
.launch(data)
}

Expand Down
2 changes: 1 addition & 1 deletion druid-shell/src/platform/gtk/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ impl WindowBuilder {
Some(Vec2::new(delta_x, delta_y))
}
e => {
eprintln!(
warn!(
"Warning: the Druid widget got some whacky scroll direction {:?}",
e
);
Expand Down
7 changes: 2 additions & 5 deletions druid/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,8 @@ image-all = ["image", "svg", "png", "jpeg", "jpeg_rayon", "gif", "bmp", "ico", "
druid-shell = { version = "0.7.0", default-features = false, path = "../druid-shell" }
druid-derive = { version = "0.4.0", path = "../druid-derive" }

log = "0.4.11"
tracing = { version = "0.1.22", features = ["log"] }
simple_logger = { version = "1.9.0", default-features = false }
tracing-subscriber = { version = "0.2.15" }
tracing = { version = "0.1.22" }
tracing-subscriber = { version = "0.2.15", features = ["fmt", "ansi"], default-features = false }
fluent-bundle = "0.12.0"
fluent-langneg = "0.13.0"
fluent-syntax = "0.9.3"
Expand All @@ -73,7 +71,6 @@ usvg = { version = "0.12.0", optional = true }
harfbuzz-sys = { version = "0.4.0", optional = true }

[target.'cfg(target_arch="wasm32")'.dependencies]
console_log = { version = "0.2.0" }
tracing-wasm = { version = "0.1.0" }
console_error_panic_hook = { version = "0.1.6" }

Expand Down
2 changes: 1 addition & 1 deletion druid/examples/anim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ pub fn main() {
.with_placeholder("You spin me right round..."),
);
AppLauncher::with_window(window)
.use_env_tracing()
.log_to_console()
.launch(())
.expect("launch failed");
}
2 changes: 1 addition & 1 deletion druid/examples/async_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub fn main() {
thread::spawn(move || generate_colors(event_sink));

launcher
.use_env_tracing()
.log_to_console()
.launch(Color::BLACK)
.expect("launch failed");
}
Expand Down
2 changes: 1 addition & 1 deletion druid/examples/calc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ pub fn main() {
in_num: false,
};
AppLauncher::with_window(window)
.use_env_tracing()
.log_to_console()
.launch(calc_state)
.expect("launch failed");
}
2 changes: 1 addition & 1 deletion druid/examples/cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ pub fn main() {
custom_desc,
};
AppLauncher::with_window(main_window)
.use_env_tracing()
.log_to_console()
.launch(data)
.expect("launch failed");
}
2 changes: 1 addition & 1 deletion druid/examples/custom_widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ impl Widget<String> for CustomWidget {
pub fn main() {
let window = WindowDesc::new(CustomWidget {}).title(LocalizedString::new("Fancy Colors"));
AppLauncher::with_window(window)
.use_env_tracing()
.log_to_console()
.launch("Druid + Piet".to_string())
.expect("launch failed");
}
Expand Down
2 changes: 1 addition & 1 deletion druid/examples/either.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ fn ui_builder() -> impl Widget<AppState> {
pub fn main() {
let main_window = WindowDesc::new(ui_builder()).title("Switcheroo");
AppLauncher::with_window(main_window)
.use_env_tracing()
.log_to_console()
.launch(AppState::default())
.expect("launch failed");
}
2 changes: 1 addition & 1 deletion druid/examples/event_viewer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ pub fn main() {

//start the application
AppLauncher::with_window(main_window)
.use_env_tracing()
.log_to_console()
.configure_env(|env, _| {
env.set(theme::UI_FONT, FontDescriptor::default().with_size(12.0));
env.set(theme::LABEL_COLOR, TEXT_COLOR);
Expand Down
2 changes: 1 addition & 1 deletion druid/examples/flex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ pub fn main() {
};

AppLauncher::with_window(main_window)
.use_env_tracing()
.log_to_console()
.launch(AppState { demo_state, params })
.expect("Failed to launch application");
}
2 changes: 1 addition & 1 deletion druid/examples/game_of_life.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ pub fn main() {
}

AppLauncher::with_window(window)
.use_env_tracing()
.log_to_console()
.launch(AppData {
grid,
drawing: false,
Expand Down
2 changes: 1 addition & 1 deletion druid/examples/hello.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub fn main() {

// start the application. Here we pass in the application state.
AppLauncher::with_window(main_window)
.use_env_tracing()
.log_to_console()
.launch(initial_state)
.expect("Failed to launch application");
}
Expand Down
2 changes: 1 addition & 1 deletion druid/examples/identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub fn main() {
counter_two: 0,
};
AppLauncher::with_window(window)
.use_env_tracing()
.log_to_console()
.launch(data)
.expect("launch failed");
}
Expand Down
2 changes: 1 addition & 1 deletion druid/examples/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ pub fn main() {
};

AppLauncher::with_window(main_window)
.use_env_tracing()
.log_to_console()
.launch(state)
.expect("Failed to launch application");
}
2 changes: 1 addition & 1 deletion druid/examples/invalidation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub fn main() {
circles: Vector::new(),
};
AppLauncher::with_window(window)
.use_env_tracing()
.log_to_console()
.launch(state)
.expect("launch failed");
}
Expand Down
2 changes: 1 addition & 1 deletion druid/examples/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub fn main() {
let window = WindowDesc::new(build_app()).title("Very flexible");

AppLauncher::with_window(window)
.use_env_tracing()
.log_to_console()
.launch(0)
.expect("launch failed");
}
2 changes: 1 addition & 1 deletion druid/examples/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub fn main() {
right,
};
AppLauncher::with_window(main_window)
.use_env_tracing()
.log_to_console()
.launch(data)
.expect("launch failed");
}
Expand Down
2 changes: 1 addition & 1 deletion druid/examples/markdown_preview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub fn main() {

// start the application
AppLauncher::with_window(main_window)
.use_env_tracing()
.log_to_console()
.launch(initial_state)
.expect("Failed to launch application");
}
Expand Down
2 changes: 1 addition & 1 deletion druid/examples/multiwin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub fn main() {
.delegate(Delegate {
windows: Vec::new(),
})
.use_env_tracing()
.log_to_console()
.launch(State::default())
.expect("launch failed");
}
Expand Down
2 changes: 1 addition & 1 deletion druid/examples/open_save.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub fn main() {
let data = "Type here.".to_owned();
AppLauncher::with_window(main_window)
.delegate(Delegate)
.use_env_tracing()
.log_to_console()
.launch(data)
.expect("launch failed");
}
Expand Down
2 changes: 1 addition & 1 deletion druid/examples/panels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ pub fn main() -> Result<(), PlatformError> {
let main_window = WindowDesc::new(build_app())
.title(LocalizedString::new("panels-demo-window-title").with_placeholder("Fancy Boxes!"));
AppLauncher::with_window(main_window)
.use_env_tracing()
.log_to_console()
.launch(())?;

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion druid/examples/scroll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub fn main() {
let window = WindowDesc::new(build_widget())
.title(LocalizedString::new("scroll-demo-window-title").with_placeholder("Scroll demo"));
AppLauncher::with_window(window)
.use_env_tracing()
.log_to_console()
.launch(0u32)
.expect("launch failed");
}
Expand Down
2 changes: 1 addition & 1 deletion druid/examples/scroll_colors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub fn main() {
);
let data = 0_u32;
AppLauncher::with_window(main_window)
.use_env_tracing()
.log_to_console()
.launch(data)
.expect("launch failed");
}
2 changes: 1 addition & 1 deletion druid/examples/split_demo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ pub fn main() {
let window = WindowDesc::new(build_app())
.title(LocalizedString::new("split-demo-window-title").with_placeholder("Split Demo"));
AppLauncher::with_window(window)
.use_env_tracing()
.log_to_console()
.launch(0u32)
.expect("launch failed");
}
2 changes: 1 addition & 1 deletion druid/examples/styled_text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub fn main() -> Result<(), PlatformError> {
};

AppLauncher::with_window(main_window)
.use_env_tracing()
.log_to_console()
.launch(data)?;

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion druid/examples/sub_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub fn main() {

// start the application
AppLauncher::with_window(main_window)
.use_env_tracing()
.log_to_console()
.launch(initial_state)
.expect("Failed to launch application");
}
Expand Down
2 changes: 1 addition & 1 deletion druid/examples/svg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub fn main() {
.title(LocalizedString::new("svg-demo-window-title").with_placeholder("Rawr!"));
let data = 0_u32;
AppLauncher::with_window(main_window)
.use_env_tracing()
.log_to_console()
.launch(data)
.expect("launch failed");
}
Expand Down
2 changes: 1 addition & 1 deletion druid/examples/switches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pub fn main() {
let window = WindowDesc::new(build_widget())
.title(LocalizedString::new("switch-demo-window-title").with_placeholder("Switch Demo"));
AppLauncher::with_window(window)
.use_env_tracing()
.log_to_console()
.launch(DemoState {
value: true,
stepper_value: 1.0,
Expand Down
2 changes: 1 addition & 1 deletion druid/examples/tabs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ pub fn main() {

// start the application
AppLauncher::with_window(main_window)
.use_env_tracing()
.log_to_console()
.launch(initial_state)
.expect("Failed to launch application");
}
Expand Down
2 changes: 1 addition & 1 deletion druid/examples/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ pub fn main() {

// start the application
AppLauncher::with_window(main_window)
.use_env_tracing()
.log_to_console()
.launch(initial_state)
.expect("Failed to launch application");
}
Expand Down
2 changes: 1 addition & 1 deletion druid/examples/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ pub fn main() {
.title(LocalizedString::new("timer-demo-window-title").with_placeholder("Look at it go!"));

AppLauncher::with_window(window)
.use_env_tracing()
.log_to_console()
.launch(0u32)
.expect("launch failed");
}
2 changes: 1 addition & 1 deletion druid/examples/transparency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub fn main() {
.title("Transparent background");

AppLauncher::with_window(window)
.use_env_tracing()
.log_to_console()
.launch("Druid + Piet".to_string())
.expect("launch failed");
}
2 changes: 1 addition & 1 deletion druid/examples/value_formatting/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub fn main() {
};

AppLauncher::with_window(main_window)
.use_env_tracing()
.log_to_console()
.launch(data)
.expect("launch failed");
}
Expand Down
2 changes: 1 addition & 1 deletion druid/examples/view_switcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub fn main() {
current_text: "Edit me!".to_string(),
};
AppLauncher::with_window(main_window)
.use_env_tracing()
.log_to_console()
.launch(data)
.expect("launch failed");
}
Expand Down
2 changes: 1 addition & 1 deletion druid/examples/widget_gallery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub fn main() {
editable_text: "edit me!".into(),
};
AppLauncher::with_window(main_window)
.use_env_tracing()
.log_to_console()
.launch(data)
.expect("launch failed");
}
Expand Down
25 changes: 9 additions & 16 deletions druid/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,43 +162,36 @@ impl<T: Data> AppLauncher<T> {
/// # Panics
///
/// Panics if the logger fails to initialize.
#[deprecated(since = "0.7.0", note = "Use use_env_tracing instead")]
#[deprecated(since = "0.7.0", note = "Use log_to_console instead")]
pub fn use_simple_logger(self) -> Self {
#[cfg(not(target_arch = "wasm32"))]
simple_logger::SimpleLogger::new()
.with_level(log::LevelFilter::Debug)
.init()
.expect("Failed to initialize logger.");
#[cfg(target_arch = "wasm32")]
console_log::init_with_level(log::Level::Debug).expect("Failed to initialize logger.");
self
self.log_to_console()
}

/// Initialize a minimal tracing subscriber with DEBUG max level for printing logs out to
/// stderr, controlled by ENV variables.
/// stderr.
///
/// This is meant for quick-and-dirty debugging. If you want more serious trace handling,
/// it's probably better to implement it yourself.
///
/// # Panics
///
/// Panics if the subscriber fails to initialize.
pub fn use_env_tracing(self) -> Self {
pub fn log_to_console(self) -> Self {
#[cfg(not(target_arch = "wasm32"))]
{
use tracing_subscriber::prelude::*;
let fmt_layer = tracing_subscriber::fmt::layer().with_target(true);
let filter_layer = tracing_subscriber::EnvFilter::try_from_default_env()
.or_else(|_| tracing_subscriber::EnvFilter::try_new("debug"))
.expect("Failed to initialize tracing subscriber");
let filter_layer = tracing_subscriber::filter::LevelFilter::DEBUG;
let fmt_layer = tracing_subscriber::fmt::layer()
// Display target (eg "my_crate::some_mod::submod") with logs
.with_target(true);

tracing_subscriber::registry()
.with(filter_layer)
.with(fmt_layer)
.init();
}
// Note - tracing-wasm might not work in headless Node.js. Probably doesn't matter anyway,
// because wasm targets will virtually always be browsers.
// because this is a GUI framework, so wasm targets will virtually always be browsers.
#[cfg(target_arch = "wasm32")]
{
console_error_panic_hook::set_once();
Expand Down
Loading