Skip to content

Commit dc01e6e

Browse files
authored
Normalize logging levels (#8579)
1 parent f114138 commit dc01e6e

File tree

27 files changed

+94
-88
lines changed

27 files changed

+94
-88
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,20 @@ One other breaking change worth noting is that in WGSL `@builtin(view_index)` no
106106

107107
By @SupaMaggie70Incorporated in [#8206](https://github.com/gfx-rs/wgpu/pull/8206).
108108

109+
#### Log Levels
110+
111+
We have received complaints about wgpu being way too log spammy at log levels `info`/`warn`/`error`. We have
112+
adjusted our log policy and changed logging such that `info` and above should be silent unless some exceptional
113+
event happens. Our new log policy is as follows:
114+
115+
- Error: if we can’t (for some reason, usually a bug) communicate an error any other way.
116+
- Warning: similar, but there may be one-shot warnings about almost certainly sub-optimal.
117+
- Info: do not use
118+
- Debug: Used for interesting events happening inside wgpu.
119+
- Trace: Used for all events that might be useful to either `wgpu` or application developers.
120+
121+
By @cwfitzgerald in [#8579](https://github.com/gfx-rs/wgpu/pull/8579).
122+
109123
### New Features
110124

111125
- Added support for transient textures on Vulkan and Metal. By @opstic in [#8247](https://github.com/gfx-rs/wgpu/pull/8247)

examples/features/src/framework.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,11 @@ fn init_logger() {
6060
let query_level: Option<log::LevelFilter> = parse_url_query_string(&query_string, "RUST_LOG")
6161
.and_then(|x| x.parse().ok());
6262

63-
// We keep wgpu at Error level, as it's very noisy.
6463
let base_level = query_level.unwrap_or(log::LevelFilter::Info);
65-
let wgpu_level = query_level.unwrap_or(log::LevelFilter::Error);
6664

6765
// On web, we use fern, as console_log doesn't have filtering on a per-module level.
6866
fern::Dispatch::new()
6967
.level(base_level)
70-
.level_for("wgpu_core", wgpu_level)
71-
.level_for("wgpu_hal", wgpu_level)
72-
.level_for("naga", wgpu_level)
7368
.chain(fern::Output::call(console_log::log))
7469
.apply()
7570
.unwrap();
@@ -79,10 +74,6 @@ fn init_logger() {
7974
// of these default filters.
8075
env_logger::builder()
8176
.filter_level(log::LevelFilter::Info)
82-
// We keep wgpu at Error level, as it's very noisy.
83-
.filter_module("wgpu_core", log::LevelFilter::Info)
84-
.filter_module("wgpu_hal", log::LevelFilter::Error)
85-
.filter_module("naga", log::LevelFilter::Error)
8677
.parse_default_env()
8778
.init();
8879
}

naga/src/back/hlsl/writer.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
441441
_ => false,
442442
})
443443
{
444-
log::info!(
444+
log::debug!(
445445
"Skipping function {:?} (name {:?}) because global {:?} is inaccessible",
446446
handle,
447447
function.name,
@@ -945,7 +945,7 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
945945

946946
if let Some(ref binding) = global.binding {
947947
if let Err(err) = self.options.resolve_resource_binding(binding) {
948-
log::info!(
948+
log::debug!(
949949
"Skipping global {:?} (name {:?}) for being inaccessible: {}",
950950
handle,
951951
global.name,
@@ -1187,7 +1187,7 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
11871187
{
11881188
Ok(bindings) => bindings,
11891189
Err(err) => {
1190-
log::info!(
1190+
log::debug!(
11911191
"Skipping global {:?} (name {:?}) for being inaccessible: {}",
11921192
handle,
11931193
global.name,

naga/src/back/spv/writer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2666,7 +2666,7 @@ impl Writer {
26662666
// because the entry point and its callees didn't use them,
26672667
// then we must skip it.
26682668
if !ep_info.dominates_global_use(info) {
2669-
log::info!("Skip function {:?}", ir_function.name);
2669+
log::debug!("Skip function {:?}", ir_function.name);
26702670
continue;
26712671
}
26722672

naga/src/front/glsl/builtins.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1669,7 +1669,7 @@ impl MacroCall {
16691669
num_args += 1;
16701670

16711671
if shadow {
1672-
log::warn!("Assuming LOD {:?} is zero", args[2],);
1672+
log::debug!("Assuming LOD {:?} is zero", args[2],);
16731673

16741674
SampleLevel::Zero
16751675
} else {
@@ -1681,7 +1681,7 @@ impl MacroCall {
16811681
num_args += 2;
16821682

16831683
if shadow {
1684-
log::warn!(
1684+
log::debug!(
16851685
"Assuming gradients {:?} and {:?} are not greater than 1",
16861686
args[2],
16871687
args[3],

naga/src/front/spv/mod.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,15 @@ impl<I: Iterator<Item = u32>> Frontend<I> {
799799
dec.specialization_constant_id = Some(self.next()?);
800800
}
801801
other => {
802-
log::warn!("Unknown decoration {other:?}");
802+
let level = match other {
803+
// Block decorations show up everywhere and we don't
804+
// really care about them, so to prevent log spam
805+
// we demote them to debug level.
806+
spirv::Decoration::Block => log::Level::Debug,
807+
_ => log::Level::Warn,
808+
};
809+
810+
log::log!(level, "Unknown decoration {other:?}");
803811
for _ in base_words + 1..inst.wc {
804812
let _var = self.next()?;
805813
}
@@ -4746,7 +4754,7 @@ impl<I: Iterator<Item = u32>> Frontend<I> {
47464754
let generator = self.next()?;
47474755
let _bound = self.next()?;
47484756
let _schema = self.next()?;
4749-
log::info!("Generated by {generator} version {version_raw:x}");
4757+
log::debug!("Generated by {generator} version {version_raw:x}");
47504758
crate::Module::default()
47514759
};
47524760

@@ -4816,7 +4824,7 @@ impl<I: Iterator<Item = u32>> Frontend<I> {
48164824
}
48174825

48184826
if !self.upgrade_atomics.is_empty() {
4819-
log::info!("Upgrading atomic pointers...");
4827+
log::debug!("Upgrading atomic pointers...");
48204828
module.upgrade_atomics(&self.upgrade_atomics)?;
48214829
}
48224830

@@ -4826,7 +4834,7 @@ impl<I: Iterator<Item = u32>> Frontend<I> {
48264834
self.process_entry_point(&mut module, ep, fun_id)?;
48274835
}
48284836

4829-
log::info!("Patching...");
4837+
log::debug!("Patching...");
48304838
{
48314839
let mut nodes = petgraph::algo::toposort(&self.function_call_graph, None)
48324840
.map_err(|cycle| Error::FunctionCallCycle(cycle.node_id()))?;
@@ -4866,11 +4874,11 @@ impl<I: Iterator<Item = u32>> Frontend<I> {
48664874
}
48674875

48684876
if !self.future_decor.is_empty() {
4869-
log::warn!("Unused item decorations: {:?}", self.future_decor);
4877+
log::debug!("Unused item decorations: {:?}", self.future_decor);
48704878
self.future_decor.clear();
48714879
}
48724880
if !self.future_member_decor.is_empty() {
4873-
log::warn!("Unused member decorations: {:?}", self.future_member_decor);
4881+
log::debug!("Unused member decorations: {:?}", self.future_member_decor);
48744882
self.future_member_decor.clear();
48754883
}
48764884

naga/src/valid/interface.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ pub enum VaryingError {
6565
MissingInterpolation,
6666
#[error("Built-in {0:?} is not available at this stage")]
6767
InvalidBuiltInStage(crate::BuiltIn),
68-
#[error("Built-in type for {0:?} is invalid")]
69-
InvalidBuiltInType(crate::BuiltIn),
68+
#[error("Built-in type for {0:?} is invalid. Found {1:?}")]
69+
InvalidBuiltInType(crate::BuiltIn, crate::TypeInner),
7070
#[error("Entry point arguments and return values must all have bindings")]
7171
MissingBinding,
7272
#[error("Struct member {0} is missing a binding")]
@@ -426,8 +426,7 @@ impl VaryingContext<'_> {
426426
return Err(VaryingError::InvalidBuiltInStage(built_in));
427427
}
428428
if !type_good {
429-
log::warn!("Wrong builtin type: {ty_inner:?}");
430-
return Err(VaryingError::InvalidBuiltInType(built_in));
429+
return Err(VaryingError::InvalidBuiltInType(built_in, ty_inner.clone()));
431430
}
432431
}
433432
crate::Binding::Location {

naga/tests/naga/wgsl_errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4090,7 +4090,7 @@ fn invalid_clip_distances() {
40904090
Err(naga::valid::ValidationError::EntryPoint {
40914091
stage: naga::ShaderStage::Vertex,
40924092
source: naga::valid::EntryPointError::Result(
4093-
naga::valid::VaryingError::InvalidBuiltInType(naga::ir::BuiltIn::ClipDistance)
4093+
naga::valid::VaryingError::InvalidBuiltInType(naga::ir::BuiltIn::ClipDistance, _)
40944094
),
40954095
..
40964096
}),

wgpu-core/src/command/ray_tracing.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ pub(crate) fn build_acceleration_structures(
340340
} in &tlas_storage
341341
{
342342
if tlas.update_mode == wgt::AccelerationStructureUpdateMode::PreferUpdate {
343-
log::info!("only rebuild implemented")
343+
log::warn!("build_acceleration_structures called with PreferUpdate, but only rebuild is implemented");
344344
}
345345
tlas_descriptors.push(hal::BuildAccelerationStructureDescriptor {
346346
entries,
@@ -941,7 +941,7 @@ fn map_blas<'a>(
941941
scratch_buffer_offset,
942942
} = storage;
943943
if blas.update_mode == wgt::AccelerationStructureUpdateMode::PreferUpdate {
944-
log::info!("only rebuild implemented")
944+
log::debug!("only rebuild implemented")
945945
}
946946
let raw = blas.try_raw(snatch_guard)?;
947947

wgpu-core/src/device/resource.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2306,9 +2306,6 @@ impl Device {
23062306
self.check_is_valid()?;
23072307
self.require_features(wgt::Features::EXPERIMENTAL_PASSTHROUGH_SHADERS)?;
23082308

2309-
// TODO: when we get to use if-let chains, this will be a little nicer!
2310-
2311-
log::info!("Backend: {}", self.backend());
23122309
let hal_shader = match self.backend() {
23132310
wgt::Backend::Vulkan => hal::ShaderInput::SpirV(
23142311
descriptor
@@ -4433,7 +4430,7 @@ impl Device {
44334430
)?;
44344431
}
44354432
_ => {
4436-
log::warn!(
4433+
log::debug!(
44374434
"The fragment stage {:?} output @location({}) values are ignored",
44384435
fragment_stage
44394436
.as_ref()

0 commit comments

Comments
 (0)