Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add start_console_logging(bool) which accepts a flag. #2102

Merged
merged 1 commit into from
Jan 22, 2023
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ You can find its changes [documented below](#070---2021-01-01).
- `Event::WindowScale` to notify widgets of the window's scale changes. ([#2335] by [@xStrom])
- `Ctx::scale` method to all contexts for widgets to easily access the window's scale. ([#2335] by [@xStrom])
- Add a public constructor to `StringCursor` ([#2319] by [@benoitryder])
- App: add start_console_logging(bool) which accepts a flag. ([#2102] by [@ratmice])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately the links aren't automatically generated. Please manually define both [#2102] and [@ratmice] at the bottom of the file.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rebased and defined the links, sorry I had missed your comment until now.


### Changed

Expand Down Expand Up @@ -580,6 +581,7 @@ Last release without a changelog :(
[@benoitryder]: https://github.com/benoitryder
[@sprocklem]: https://github.com/sprocklem
[@cbondurant]: https://github.com/cbondurant
[@ratmice]: https://github.com/ratmice

[#599]: https://github.com/linebender/druid/pull/599
[#611]: https://github.com/linebender/druid/pull/611
Expand Down Expand Up @@ -863,6 +865,7 @@ Last release without a changelog :(
[#2036]: https://github.com/linebender/druid/pull/2036
[#2064]: https://github.com/linebender/druid/pull/2064
[#1979]: https://github.com/linebender/druid/pull/1979
[#2102]: https://github.com/linebender/druid/pull/2102
[#2119]: https://github.com/linebender/druid/pull/2119
[#2111]: https://github.com/linebender/druid/pull/2111
[#2117]: https://github.com/linebender/druid/pull/2117
Expand Down
18 changes: 15 additions & 3 deletions druid/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,17 @@ impl<T: Data> AppLauncher<T> {
///
/// # Panics
///
/// Panics if the subscriber fails to initialize, for example if a `tracing`/`tracing_wasm`
/// global logger was already set.
pub fn log_to_console(self) -> Self {
/// Panics if `enable` is `true` and the subscriber fails to initialize,
/// for example if a `tracing`/`tracing_wasm` global logger was already set.
///
/// Never panics when `enable` is `false`, or have any other side effect.
///
/// Passing in false is useful if you want to enable a global logger as feature
/// but log to console otherwise.
pub fn start_console_logging(self, enable: bool) -> Self {
if !enable {
return self;
}
#[cfg(not(target_arch = "wasm32"))]
{
use tracing_subscriber::prelude::*;
Expand All @@ -219,6 +227,10 @@ impl<T: Data> AppLauncher<T> {
self
}

/// Calls `start_console_logging` with `true`.
pub fn log_to_console(self) -> Self {
self.start_console_logging(true)
}
/// Use custom localization resource
///
/// `resources` is a list of file names that contain strings. `base_dir`
Expand Down