Skip to content
This repository was archived by the owner on Nov 6, 2020. It is now read-only.

Commit dd2c279

Browse files
debrisandresilva
authored andcommitted
use atty instead of isatty (#8365)
1 parent 6737484 commit dd2c279

File tree

6 files changed

+39
-30
lines changed

6 files changed

+39
-30
lines changed

Cargo.lock

Lines changed: 27 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ semver = "0.9"
2121
ansi_term = "0.10"
2222
parking_lot = "0.5"
2323
regex = "0.2"
24-
isatty = "0.1"
24+
atty = "0.2.8"
2525
toml = "0.4"
2626
serde = "1.0"
2727
serde_json = "1.0"

logger/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ authors = ["Parity Technologies <[email protected]>"]
88
[dependencies]
99
log = "0.3"
1010
env_logger = "0.4"
11-
isatty = "0.1"
11+
atty = "0.2"
1212
lazy_static = "1.0"
1313
regex = "0.2"
1414
time = "0.1"

logger/src/lib.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,23 @@
1616

1717
//! Logger for parity executables
1818
19+
extern crate ansi_term;
1920
extern crate arrayvec;
21+
extern crate atty;
22+
extern crate env_logger;
2023
extern crate log as rlog;
21-
extern crate isatty;
24+
extern crate parking_lot;
2225
extern crate regex;
23-
extern crate env_logger;
2426
extern crate time;
27+
2528
#[macro_use]
2629
extern crate lazy_static;
27-
extern crate parking_lot;
28-
extern crate ansi_term;
2930

3031
mod rotating;
3132

3233
use std::{env, thread, fs};
3334
use std::sync::{Weak, Arc};
3435
use std::io::Write;
35-
use isatty::{stderr_isatty, stdout_isatty};
3636
use env_logger::LogBuilder;
3737
use regex::Regex;
3838
use ansi_term::Colour;
@@ -86,7 +86,7 @@ pub fn setup_log(config: &Config) -> Result<Arc<RotatingLogger>, String> {
8686
builder.parse(s);
8787
}
8888

89-
let isatty = stderr_isatty();
89+
let isatty = atty::is(atty::Stream::Stderr);
9090
let enable_color = config.color && isatty;
9191
let logs = Arc::new(RotatingLogger::new(levels));
9292
let logger = logs.clone();
@@ -122,7 +122,7 @@ pub fn setup_log(config: &Config) -> Result<Arc<RotatingLogger>, String> {
122122
let _ = file.write_all(b"\n");
123123
}
124124
logger.append(removed_color);
125-
if !isatty && record.level() <= LogLevel::Info && stdout_isatty() {
125+
if !isatty && record.level() <= LogLevel::Info && atty::is(atty::Stream::Stdout) {
126126
// duplicate INFO/WARN output to console
127127
println!("{}", ret);
128128
}

parity/informant.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use std::sync::{Arc};
2222
use std::sync::atomic::{AtomicUsize, AtomicBool, Ordering as AtomicOrdering};
2323
use std::time::{Instant, Duration};
2424

25+
use atty;
2526
use ethcore::client::{
2627
BlockId, BlockChainClient, ChainInfo, BlockInfo, BlockChainInfo,
2728
BlockQueueInfo, ChainNotify, ClientReport, Client, ClientIoMessage
@@ -31,7 +32,6 @@ use ethcore::snapshot::{RestorationStatus, SnapshotService as SS};
3132
use ethcore::snapshot::service::Service as SnapshotService;
3233
use sync::{LightSyncProvider, LightSync, SyncProvider, ManageNetwork};
3334
use io::{TimerToken, IoContext, IoHandler};
34-
use isatty::{stdout_isatty};
3535
use light::Cache as LightDataCache;
3636
use light::client::LightChainClient;
3737
use number_prefix::{binary_prefix, Standalone, Prefixed};
@@ -293,7 +293,7 @@ impl<T: InformantData> Informant<T> {
293293

294294
*self.last_tick.write() = Instant::now();
295295

296-
let paint = |c: Style, t: String| match self.with_color && stdout_isatty() {
296+
let paint = |c: Style, t: String| match self.with_color && atty::is(atty::Stream::Stdout) {
297297
true => format!("{}", c.paint(t)),
298298
false => t,
299299
};

parity/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ extern crate env_logger;
2929
extern crate fdlimit;
3030
extern crate futures;
3131
extern crate futures_cpupool;
32-
extern crate isatty;
32+
extern crate atty;
3333
extern crate jsonrpc_core;
3434
extern crate num_cpus;
3535
extern crate number_prefix;

0 commit comments

Comments
 (0)