Skip to content

Commit 4db5e87

Browse files
committed
fix!: Rename termcolor/atty features
This makes it easier to change dependencies in the future. BREAKING CHANGE: `termcolor` -> `color` and `atty` -> `auto-color`
1 parent 660cf7f commit 4db5e87

File tree

6 files changed

+21
-18
lines changed

6 files changed

+21
-18
lines changed

Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ pre-release-replacements = [
3737
]
3838

3939
[features]
40-
default = ["termcolor", "atty", "humantime", "regex"]
40+
default = ["auto-color", "humantime", "regex"]
41+
color = ["dep:termcolor"]
42+
auto-color = ["dep:atty", "color"]
43+
humantime = ["dep:humantime"]
44+
regex = ["dep:regex"]
4145

4246
[dependencies]
4347
log = { version = "0.4.8", features = ["std"] }

ci/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ mod permute;
22
mod task;
33

44
fn main() {
5-
let features = ["termcolor", "humantime", "atty", "regex"];
5+
let features = ["color", "humantime", "auto-color", "regex"];
66

77
// Run a default build
88
if !task::test(Default::default()) {

examples/custom_format.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ $ export MY_LOG_STYLE=never
1717
If you want to control the logging output completely, see the `custom_logger` example.
1818
*/
1919

20-
#[cfg(all(feature = "termcolor", feature = "humantime"))]
20+
#[cfg(all(feature = "color", feature = "humantime"))]
2121
fn main() {
2222
use env_logger::{fmt::Color, Builder, Env};
2323

@@ -50,5 +50,5 @@ fn main() {
5050
log::info!("a log from `MyLogger`");
5151
}
5252

53-
#[cfg(not(all(feature = "termcolor", feature = "humantime")))]
53+
#[cfg(not(all(feature = "color", feature = "humantime")))]
5454
fn main() {}

src/fmt/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,9 @@ impl Builder {
202202
}
203203
}
204204

205-
#[cfg(feature = "termcolor")]
205+
#[cfg(feature = "color")]
206206
type SubtleStyle = StyledValue<'static, &'static str>;
207-
#[cfg(not(feature = "termcolor"))]
207+
#[cfg(not(feature = "color"))]
208208
type SubtleStyle = &'static str;
209209

210210
/// The default format.
@@ -233,7 +233,7 @@ impl<'a> DefaultFormat<'a> {
233233
}
234234

235235
fn subtle_style(&self, text: &'static str) -> SubtleStyle {
236-
#[cfg(feature = "termcolor")]
236+
#[cfg(feature = "color")]
237237
{
238238
self.buf
239239
.style()
@@ -242,7 +242,7 @@ impl<'a> DefaultFormat<'a> {
242242
.clone()
243243
.into_value(text)
244244
}
245-
#[cfg(not(feature = "termcolor"))]
245+
#[cfg(not(feature = "color"))]
246246
{
247247
text
248248
}
@@ -268,11 +268,11 @@ impl<'a> DefaultFormat<'a> {
268268
}
269269

270270
let level = {
271-
#[cfg(feature = "termcolor")]
271+
#[cfg(feature = "color")]
272272
{
273273
self.buf.default_styled_level(record.level())
274274
}
275-
#[cfg(not(feature = "termcolor"))]
275+
#[cfg(not(feature = "color"))]
276276
{
277277
record.level()
278278
}

src/fmt/writer/atty.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
/*
22
This internal module contains the terminal detection implementation.
33
4-
If the `atty` crate is available then we use it to detect whether we're
5-
attached to a particular TTY. If the `atty` crate is not available we
6-
assume we're not attached to anything. This effectively prevents styles
7-
from being printed.
4+
If the `auto-color` feature is enabled then we detect whether we're attached to a particular TTY.
5+
Otherwise, assume we're not attached to anything. This effectively prevents styles from being
6+
printed.
87
*/
98

10-
#[cfg(feature = "atty")]
9+
#[cfg(feature = "auto-color")]
1110
mod imp {
1211
pub(in crate::fmt) fn is_stdout() -> bool {
1312
atty::is(atty::Stream::Stdout)
@@ -18,7 +17,7 @@ mod imp {
1817
}
1918
}
2019

21-
#[cfg(not(feature = "atty"))]
20+
#[cfg(not(feature = "auto-color"))]
2221
mod imp {
2322
pub(in crate::fmt) fn is_stdout() -> bool {
2423
false

src/fmt/writer/termcolor/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ Its public API is available when the `termcolor` crate is available.
55
The terminal printing is shimmed when the `termcolor` crate is not available.
66
*/
77

8-
#[cfg_attr(feature = "termcolor", path = "extern_impl.rs")]
9-
#[cfg_attr(not(feature = "termcolor"), path = "shim_impl.rs")]
8+
#[cfg_attr(feature = "color", path = "extern_impl.rs")]
9+
#[cfg_attr(not(feature = "color"), path = "shim_impl.rs")]
1010
mod imp;
1111

1212
pub(in crate::fmt) use self::imp::*;

0 commit comments

Comments
 (0)