Skip to content

Commit

Permalink
[FEATURE] Configurable verbosity for rendy/backend-gfx
Browse files Browse the repository at this point in the history
  • Loading branch information
AidaPaul committed Nov 22, 2019
1 parent 8517be9 commit e5d1e59
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
2 changes: 2 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ The format is based on [Keep a Changelog][kc], and this project adheres to
- Log warning when `amethyst_test::WaitForLoad` has not completed in 10 seconds. ([#1984])
- Derive `Copy` and `PartialEq` for `amethyst::renderer::resources::Tint`. ([#2033])
- Derive `Hash` for `amethyst::input::{Button, ControllerButton, ScrollDirection}`. ([#2041])
- Add rendy/gfx-backend log verbosity through configuration. ([#1652])

### Changed

Expand Down Expand Up @@ -70,6 +71,7 @@ The format is based on [Keep a Changelog][kc], and this project adheres to
[#2029]: https://github.com/amethyst/amethyst/pull/2029
[#2033]: https://github.com/amethyst/amethyst/pull/2033
[#2041]: https://github.com/amethyst/amethyst/pull/2041
[#1652]: https://github.com/amethyst/amethyst/issues/1652


## [0.13.3] - 2019-10-4
Expand Down
29 changes: 21 additions & 8 deletions src/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ pub struct LoggerConfig {
pub log_file: Option<PathBuf>,
/// If set, allows the config values to be overriden via the corresponding environmental variables.
pub allow_env_override: bool,
/// Sets a different level for gfx_device_gl if Some
pub log_gfx_device_level: Option<LevelFilter>,
/// Sets a different level for gfx_backend if Some
pub log_gfx_backend_level: Option<LevelFilter>,
/// Sets a different level for gfx_rendy if Some
pub log_gfx_rendy_level: Option<LevelFilter>,
}

impl Default for LoggerConfig {
Expand All @@ -38,7 +40,8 @@ impl Default for LoggerConfig {
level_filter: LevelFilter::Info,
log_file: None,
allow_env_override: true,
log_gfx_device_level: Some(LevelFilter::Warn),
log_gfx_backend_level: Some(LevelFilter::Warn),
log_gfx_rendy_level: Some(LevelFilter::Warn),
}
}
}
Expand Down Expand Up @@ -110,11 +113,21 @@ impl Logger {
StdoutLog::Off => {}
}

if let Some(log_gfx_device_level) = config.log_gfx_device_level {
logger.dispatch = logger
.dispatch
.level_for("gfx_device_gl", log_gfx_device_level);
}
let log_gfx_backend_level = config.log_gfx_backend_level.unwrap();
let log_gfx_rendy_level = config.log_gfx_rendy_level.unwrap();

logger.dispatch = logger
.dispatch
.level_for("gfx_backend_empty", log_gfx_backend_le vel)
.level_for("gfx_backend_vulkan", log_gfx_backend_level)
.level_for("gfx_backend_dx12", log_gfx_backend_level)
.level_for("gfx_backend_metal", log_gfx_backend_level)
.level_for("rendy_factory::factory", log_gfx_rendy_level)
.level_for("rendy_memory::allocator::dynamic", log_gfx_rendy_level)
.level_for("rendy_graph::node::render::pass", log_gfx_rendy_level)
.level_for("rendy_graph::graph", log_gfx_rendy_level)
.level_for("rendy_memory::allocator::linear", log_gfx_rendy_level)
.level_for("rendy_wsi", log_gfx_rendy_level);

if let Some(path) = config.log_file {
if let Ok(log_file) = fern::log_file(path) {
Expand Down

0 comments on commit e5d1e59

Please sign in to comment.