1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-30 13:20:05 -04:00

Use tracing crate for logging (#1192)

* egui_web: use tracing crate
* egui_glow: use tracing crate
* Log at the debug level
* egui_demo_app: enable tracing to log to stdout
* Use tracing in egui-winit
* Add opt-in tracing support to egui
This commit is contained in:
Emil Ernerfeldt
2022-02-01 12:27:39 +01:00
committed by GitHub
parent 1f03f53dc0
commit c6ac1827f6
28 changed files with 194 additions and 107 deletions

View File

@@ -29,7 +29,7 @@ impl Clipboard {
match clipboard.get_contents() {
Ok(contents) => Some(contents),
Err(err) => {
eprintln!("Paste error: {}", err);
tracing::error!("Paste error: {}", err);
None
}
}
@@ -46,7 +46,7 @@ impl Clipboard {
if let Some(clipboard) = &mut self.copypasta {
use copypasta::ClipboardProvider as _;
if let Err(err) = clipboard.set_contents(text) {
eprintln!("Copy/Cut error: {}", err);
tracing::error!("Copy/Cut error: {}", err);
}
}
@@ -62,7 +62,7 @@ fn init_copypasta() -> Option<copypasta::ClipboardContext> {
match copypasta::ClipboardContext::new() {
Ok(clipboard) => Some(clipboard),
Err(err) => {
eprintln!("Failed to initialize clipboard: {}", err);
tracing::error!("Failed to initialize clipboard: {}", err);
None
}
}

View File

@@ -577,12 +577,12 @@ impl State {
fn open_url_in_browser(_url: &str) {
#[cfg(feature = "webbrowser")]
if let Err(err) = webbrowser::open(_url) {
eprintln!("Failed to open url: {}", err);
tracing::warn!("Failed to open url: {}", err);
}
#[cfg(not(feature = "webbrowser"))]
{
eprintln!("Cannot open url - feature \"links\" not enabled.");
tracing::warn!("Cannot open url - feature \"links\" not enabled.");
}
}

View File

@@ -15,11 +15,11 @@ impl Default for ScreenReader {
fn default() -> Self {
let tts = match tts::Tts::default() {
Ok(screen_reader) => {
eprintln!("Initialized screen reader.");
tracing::debug!("Initialized screen reader.");
Some(screen_reader)
}
Err(err) => {
eprintln!("Failed to load screen reader: {}", err);
tracing::warn!("Failed to load screen reader: {}", err);
None
}
};
@@ -38,10 +38,10 @@ impl ScreenReader {
return;
}
if let Some(tts) = &mut self.tts {
eprintln!("Speaking: {:?}", text);
tracing::debug!("Speaking: {:?}", text);
let interrupt = true;
if let Err(err) = tts.speak(text, interrupt) {
eprintln!("Failed to read: {}", err);
tracing::warn!("Failed to read: {}", err);
}
}
}