Remove `log` feature (#7583)

This commit is contained in:
Emil Ernerfeldt 2025-10-02 20:09:48 +02:00 committed by GitHub
parent bd45406fad
commit 6579bb910b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
16 changed files with 16 additions and 49 deletions

View File

@ -143,14 +143,7 @@ Light Theme:
<img src="https://github.com/user-attachments/assets/2e38972c-a444-4894-b32f-47a2719cf369" width="50%"> <img src="https://github.com/user-attachments/assets/2e38972c-a444-4894-b32f-47a2719cf369" width="50%">
## Dependencies ## Dependencies
`egui` has a minimal set of default dependencies: `egui` has a minimal set of default dependencies.
* [`ab_glyph`](https://crates.io/crates/ab_glyph)
* [`ahash`](https://crates.io/crates/ahash)
* [`bitflags`](https://crates.io/crates/bitflags)
* [`nohash-hasher`](https://crates.io/crates/nohash-hasher)
* [`parking_lot`](https://crates.io/crates/parking_lot)
Heavier dependencies are kept out of `egui`, even as opt-in. Heavier dependencies are kept out of `egui`, even as opt-in.
All code in `egui` is Wasm-friendly (even outside a browser). All code in `egui` is Wasm-friendly (even outside a browser).

View File

@ -124,10 +124,7 @@ x11 = [
__screenshot = [] __screenshot = []
[dependencies] [dependencies]
egui = { workspace = true, default-features = false, features = [ egui = { workspace = true, default-features = false, features = ["bytemuck"] }
"bytemuck",
"log",
] }
ahash.workspace = true ahash.workspace = true
document-features.workspace = true document-features.workspace = true

View File

@ -55,7 +55,7 @@ wayland = ["winit/wayland", "bytemuck"]
x11 = ["winit/x11", "bytemuck"] x11 = ["winit/x11", "bytemuck"]
[dependencies] [dependencies]
egui = { workspace = true, default-features = false, features = ["log"] } egui = { workspace = true, default-features = false }
log.workspace = true log.workspace = true
profiling.workspace = true profiling.workspace = true

View File

@ -48,9 +48,6 @@ color-hex = ["epaint/color-hex"]
## If you plan on specifying your own fonts you may disable this feature. ## If you plan on specifying your own fonts you may disable this feature.
default_fonts = ["epaint/default_fonts"] default_fonts = ["epaint/default_fonts"]
## Turn on the `log` feature, that makes egui log some errors using the [`log`](https://docs.rs/log) crate.
log = ["dep:log", "epaint/log"]
## [`mint`](https://docs.rs/mint) enables interoperability with other math libraries such as [`glam`](https://docs.rs/glam) and [`nalgebra`](https://docs.rs/nalgebra). ## [`mint`](https://docs.rs/mint) enables interoperability with other math libraries such as [`glam`](https://docs.rs/glam) and [`nalgebra`](https://docs.rs/nalgebra).
mint = ["epaint/mint"] mint = ["epaint/mint"]
@ -80,6 +77,7 @@ epaint = { workspace = true, default-features = false }
ahash.workspace = true ahash.workspace = true
bitflags.workspace = true bitflags.workspace = true
log.workspace = true
nohash-hasher.workspace = true nohash-hasher.workspace = true
profiling.workspace = true profiling.workspace = true
smallvec.workspace = true smallvec.workspace = true
@ -93,6 +91,5 @@ backtrace = { workspace = true, optional = true }
## Enable this when generating docs. ## Enable this when generating docs.
document-features = { workspace = true, optional = true } document-features = { workspace = true, optional = true }
log = { workspace = true, optional = true }
ron = { workspace = true, optional = true } ron = { workspace = true, optional = true }
serde = { workspace = true, optional = true, features = ["derive", "rc"] } serde = { workspace = true, optional = true, features = ["derive", "rc"] }

View File

@ -535,7 +535,7 @@ impl ContextImpl {
// New font definition loaded, so we need to reload all fonts. // New font definition loaded, so we need to reload all fonts.
self.fonts = None; self.fonts = None;
self.font_definitions = font_definitions; self.font_definitions = font_definitions;
#[cfg(feature = "log")]
log::trace!("Loading new font definitions"); log::trace!("Loading new font definitions");
} }
@ -559,7 +559,6 @@ impl ContextImpl {
.insert(font.name, Arc::new(font.data)); .insert(font.name, Arc::new(font.data));
} }
#[cfg(feature = "log")]
log::trace!("Adding new fonts"); log::trace!("Adding new fonts");
} }
@ -568,7 +567,6 @@ impl ContextImpl {
let mut is_new = false; let mut is_new = false;
let fonts = self.fonts.get_or_insert_with(|| { let fonts = self.fonts.get_or_insert_with(|| {
#[cfg(feature = "log")]
log::trace!("Creating new Fonts"); log::trace!("Creating new Fonts");
is_new = true; is_new = true;
@ -806,7 +804,6 @@ impl Context {
} }
if max_passes <= output.platform_output.num_completed_passes { if max_passes <= output.platform_output.num_completed_passes {
#[cfg(feature = "log")]
log::debug!( log::debug!(
"Ignoring call request_discard, because max_passes={max_passes}. Requested from {:?}", "Ignoring call request_discard, because max_passes={max_passes}. Requested from {:?}",
output.platform_output.request_discard_reasons output.platform_output.request_discard_reasons
@ -1819,7 +1816,6 @@ impl Context {
let cause = RepaintCause::new_reason(reason); let cause = RepaintCause::new_reason(reason);
self.output_mut(|o| o.request_discard_reasons.push(cause)); self.output_mut(|o| o.request_discard_reasons.push(cause));
#[cfg(feature = "log")]
log::trace!( log::trace!(
"request_discard: {}", "request_discard: {}",
if self.will_discard() { if self.will_discard() {
@ -2525,7 +2521,6 @@ impl ContextImpl {
let parent = *self.viewport_parents.entry(id).or_default(); let parent = *self.viewport_parents.entry(id).or_default();
if !all_viewport_ids.contains(&parent) { if !all_viewport_ids.contains(&parent) {
#[cfg(feature = "log")]
log::debug!( log::debug!(
"Removing viewport {:?} ({:?}): the parent is gone", "Removing viewport {:?} ({:?}): the parent is gone",
id, id,
@ -2538,7 +2533,6 @@ impl ContextImpl {
let is_our_child = parent == ended_viewport_id && id != ViewportId::ROOT; let is_our_child = parent == ended_viewport_id && id != ViewportId::ROOT;
if is_our_child { if is_our_child {
if !viewport.used { if !viewport.used {
#[cfg(feature = "log")]
log::debug!( log::debug!(
"Removing viewport {:?} ({:?}): it was never used this pass", "Removing viewport {:?} ({:?}): it was never used this pass",
id, id,
@ -2637,7 +2631,6 @@ impl Context {
let texture_atlas = if let Some(fonts) = ctx.fonts.as_ref() { let texture_atlas = if let Some(fonts) = ctx.fonts.as_ref() {
fonts.texture_atlas() fonts.texture_atlas()
} else { } else {
#[cfg(feature = "log")]
log::warn!("No font size matching {pixels_per_point} pixels per point found."); log::warn!("No font size matching {pixels_per_point} pixels per point found.");
ctx.fonts ctx.fonts
.iter() .iter()

View File

@ -154,7 +154,6 @@ impl PaintList {
#[inline(always)] #[inline(always)]
pub fn set(&mut self, idx: ShapeIdx, clip_rect: Rect, shape: Shape) { pub fn set(&mut self, idx: ShapeIdx, clip_rect: Rect, shape: Shape) {
if self.0.len() <= idx.0 { if self.0.len() <= idx.0 {
#[cfg(feature = "log")]
log::warn!("Index {} is out of bounds for PaintList", idx.0); log::warn!("Index {} is out of bounds for PaintList", idx.0);
return; return;
} }

View File

@ -19,7 +19,6 @@ impl DefaultBytesLoader {
.or_insert_with_key(|_uri| { .or_insert_with_key(|_uri| {
let bytes: Bytes = bytes.into(); let bytes: Bytes = bytes.into();
#[cfg(feature = "log")]
log::trace!("loaded {} bytes for uri {_uri:?}", bytes.len()); log::trace!("loaded {} bytes for uri {_uri:?}", bytes.len());
bytes bytes
@ -53,14 +52,12 @@ impl BytesLoader for DefaultBytesLoader {
} }
fn forget(&self, uri: &str) { fn forget(&self, uri: &str) {
#[cfg(feature = "log")]
log::trace!("forget {uri:?}"); log::trace!("forget {uri:?}");
self.cache.lock().remove(uri); self.cache.lock().remove(uri);
} }
fn forget_all(&self) { fn forget_all(&self) {
#[cfg(feature = "log")]
log::trace!("forget all"); log::trace!("forget all");
self.cache.lock().clear(); self.cache.lock().clear();

View File

@ -102,14 +102,12 @@ impl TextureLoader for DefaultTextureLoader {
} }
fn forget(&self, uri: &str) { fn forget(&self, uri: &str) {
#[cfg(feature = "log")]
log::trace!("forget {uri:?}"); log::trace!("forget {uri:?}");
self.cache.lock().retain(|key, _value| key.uri != uri); self.cache.lock().retain(|key, _value| key.uri != uri);
} }
fn forget_all(&self) { fn forget_all(&self) {
#[cfg(feature = "log")]
log::trace!("forget all"); log::trace!("forget all");
self.cache.lock().clear(); self.cache.lock().clear();

View File

@ -68,7 +68,6 @@ impl OperatingSystem {
{ {
Self::Nix Self::Nix
} else { } else {
#[cfg(feature = "log")]
log::warn!( log::warn!(
"egui: Failed to guess operating system from User-Agent {:?}. Please file an issue at https://github.com/emilk/egui/issues", "egui: Failed to guess operating system from User-Agent {:?}. Please file an issue at https://github.com/emilk/egui/issues",
user_agent user_agent

View File

@ -1248,7 +1248,6 @@ impl Ui {
if let Some(tag) = tag { if let Some(tag) = tag {
tag.set_close(); tag.set_close();
} else { } else {
#[cfg(feature = "log")]
log::warn!("Called ui.close() on a Ui that has no closable parent."); log::warn!("Called ui.close() on a Ui that has no closable parent.");
} }
} }
@ -1277,7 +1276,6 @@ impl Ui {
if let Some(tag) = tag { if let Some(tag) = tag {
tag.set_close(); tag.set_close();
} else { } else {
#[cfg(feature = "log")]
log::warn!("Called ui.close_kind({ui_kind:?}) on ui with no such closable parent."); log::warn!("Called ui.close_kind({ui_kind:?}) on ui with no such closable parent.");
} }
} }

View File

@ -291,7 +291,6 @@ fn from_ron_str<T: serde::de::DeserializeOwned>(ron: &str) -> Option<T> {
match ron::from_str::<T>(ron) { match ron::from_str::<T>(ron) {
Ok(value) => Some(value), Ok(value) => Some(value),
Err(_err) => { Err(_err) => {
#[cfg(feature = "log")]
log::warn!( log::warn!(
"egui: Failed to deserialize {} from memory: {}, ron error: {:?}", "egui: Failed to deserialize {} from memory: {}, ron error: {:?}",
std::any::type_name::<T>(), std::any::type_name::<T>(),

View File

@ -53,7 +53,7 @@ chrono = { version = "0.4", default-features = false, features = [
eframe = { workspace = true, default-features = false, features = [ eframe = { workspace = true, default-features = false, features = [
"web_screen_reader", "web_screen_reader",
] } ] }
egui = { workspace = true, features = ["callstack", "default", "log"] } egui = { workspace = true, features = ["callstack", "default"] }
egui_demo_lib = { workspace = true, features = ["default", "chrono"] } egui_demo_lib = { workspace = true, features = ["default", "chrono"] }
egui_extras = { workspace = true, features = ["default", "image"] } egui_extras = { workspace = true, features = ["default", "image"] }
image = { workspace = true, default-features = false, features = [ image = { workspace = true, default-features = false, features = [
@ -70,7 +70,11 @@ puffin = { workspace = true, optional = true }
puffin_http = { workspace = true, optional = true } puffin_http = { workspace = true, optional = true }
# Enable both WebGL & WebGPU when targeting the web (these features have no effect when not targeting wasm32) # Enable both WebGL & WebGPU when targeting the web (these features have no effect when not targeting wasm32)
# Also enable the default features so we have a supported backend for every platform. # Also enable the default features so we have a supported backend for every platform.
wgpu = { workspace = true, features = ["default", "webgpu", "webgl"], optional = true } wgpu = { workspace = true, features = [
"default",
"webgpu",
"webgl",
], optional = true }
# feature "http": # feature "http":

View File

@ -44,9 +44,6 @@ color-hex = ["ecolor/color-hex"]
## If you plan on specifying your own fonts you may disable this feature. ## If you plan on specifying your own fonts you may disable this feature.
default_fonts = ["epaint_default_fonts"] default_fonts = ["epaint_default_fonts"]
## Turn on the `log` feature, that makes egui log some errors using the [`log`](https://docs.rs/log) crate.
log = ["dep:log"]
## [`mint`](https://docs.rs/mint) enables interoperability with other math libraries such as [`glam`](https://docs.rs/glam) and [`nalgebra`](https://docs.rs/nalgebra). ## [`mint`](https://docs.rs/mint) enables interoperability with other math libraries such as [`glam`](https://docs.rs/glam) and [`nalgebra`](https://docs.rs/nalgebra).
mint = ["emath/mint"] mint = ["emath/mint"]
@ -71,6 +68,7 @@ ecolor.workspace = true
ab_glyph = "0.2.11" ab_glyph = "0.2.11"
ahash.workspace = true ahash.workspace = true
log.workspace = true
nohash-hasher.workspace = true nohash-hasher.workspace = true
parking_lot.workspace = true # Using parking_lot over std::sync::Mutex gives 50% speedups in some real-world scenarios. parking_lot.workspace = true # Using parking_lot over std::sync::Mutex gives 50% speedups in some real-world scenarios.
profiling = { workspace = true} profiling = { workspace = true}
@ -81,7 +79,6 @@ bytemuck = { workspace = true, optional = true, features = ["derive"] }
## Enable this when generating docs. ## Enable this when generating docs.
document-features = { workspace = true, optional = true } document-features = { workspace = true, optional = true }
log = { workspace = true, optional = true }
rayon = { version = "1.7", optional = true } rayon = { version = "1.7", optional = true }
## Allow serialization using [`serde`](https://docs.rs/serde) . ## Allow serialization using [`serde`](https://docs.rs/serde) .

View File

@ -2000,12 +2000,10 @@ impl Tessellator {
} }
if galley.pixels_per_point != self.pixels_per_point { if galley.pixels_per_point != self.pixels_per_point {
let warn = "epaint: WARNING: pixels_per_point (dpi scale) have changed between text layout and tessellation. \ log::warn!(
You must recreate your text shapes if pixels_per_point changes."; "epaint: WARNING: pixels_per_point (dpi scale) have changed between text layout and tessellation. \
#[cfg(feature = "log")] You must recreate your text shapes if pixels_per_point changes."
log::warn!("{warn}"); );
#[cfg(not(feature = "log"))]
println!("{warn}");
} }
out.vertices.reserve(galley.num_vertices); out.vertices.reserve(galley.num_vertices);

View File

@ -463,7 +463,6 @@ impl CachedFamily {
.glyph_info_no_cache_or_fallback(PRIMARY_REPLACEMENT_CHAR, fonts_by_id) .glyph_info_no_cache_or_fallback(PRIMARY_REPLACEMENT_CHAR, fonts_by_id)
.or_else(|| slf.glyph_info_no_cache_or_fallback(FALLBACK_REPLACEMENT_CHAR, fonts_by_id)) .or_else(|| slf.glyph_info_no_cache_or_fallback(FALLBACK_REPLACEMENT_CHAR, fonts_by_id))
.unwrap_or_else(|| { .unwrap_or_else(|| {
#[cfg(feature = "log")]
log::warn!( log::warn!(
"Failed to find replacement characters {PRIMARY_REPLACEMENT_CHAR:?} or {FALLBACK_REPLACEMENT_CHAR:?}. Will use empty glyph." "Failed to find replacement characters {PRIMARY_REPLACEMENT_CHAR:?} or {FALLBACK_REPLACEMENT_CHAR:?}. Will use empty glyph."
); );

View File

@ -238,7 +238,6 @@ impl TextureAtlas {
if required_height > self.max_height() { if required_height > self.max_height() {
// This is a bad place to be - we need to start reusing space :/ // This is a bad place to be - we need to start reusing space :/
#[cfg(feature = "log")]
log::warn!("epaint texture atlas overflowed!"); log::warn!("epaint texture atlas overflowed!");
self.cursor = (0, self.image.height() / 3); // Restart a bit down - the top of the atlas has too many important things in it self.cursor = (0, self.image.height() / 3); // Restart a bit down - the top of the atlas has too many important things in it