mirror of
https://github.com/openharmony/third_party_rust_env_logger.git
synced 2026-07-19 23:25:10 -04:00
Add Style::set_dimmed to support dimmed text
This commit is contained in:
+1
-1
@@ -23,7 +23,7 @@ members = [
|
||||
[dependencies]
|
||||
log = { version = "0.4.8", features = ["std"] }
|
||||
regex = { version = "1.0.3", optional = true, default-features=false, features=["std", "perf"] }
|
||||
termcolor = { version = "1.0.2", optional = true }
|
||||
termcolor = { version = "1.1.1", optional = true }
|
||||
humantime = { version = "2.0.0", optional = true }
|
||||
atty = { version = "0.2.5", optional = true }
|
||||
|
||||
|
||||
@@ -339,6 +339,33 @@ impl Style {
|
||||
self
|
||||
}
|
||||
|
||||
/// Set whether the text is dimmed.
|
||||
///
|
||||
/// If `yes` is true then text will be written in a dimmer color.
|
||||
/// If `yes` is false then text will be written in the default color.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// Create a style with dimmed text:
|
||||
///
|
||||
/// ```
|
||||
/// use std::io::Write;
|
||||
///
|
||||
/// let mut builder = env_logger::Builder::new();
|
||||
///
|
||||
/// builder.format(|buf, record| {
|
||||
/// let mut style = buf.style();
|
||||
///
|
||||
/// style.set_dimmed(true);
|
||||
///
|
||||
/// writeln!(buf, "{}", style.value(record.args()))
|
||||
/// });
|
||||
/// ```
|
||||
pub fn set_dimmed(&mut self, yes: bool) -> &mut Style {
|
||||
self.spec.set_dimmed(yes);
|
||||
self
|
||||
}
|
||||
|
||||
/// Set the background color.
|
||||
///
|
||||
/// # Examples
|
||||
|
||||
Reference in New Issue
Block a user