mirror of
https://github.com/ouch-org/ouch.git
synced 2025-06-07 03:55:28 +00:00
fix unaligned output when using parallelism
This commit is contained in:
parent
c0e053136f
commit
10d530d236
@ -1,5 +1,7 @@
|
|||||||
//! Macros used on ouch.
|
//! Macros used on ouch.
|
||||||
|
|
||||||
|
use std::io;
|
||||||
|
|
||||||
/// Macro that prints \[INFO\] messages, wraps [`eprintln`].
|
/// Macro that prints \[INFO\] messages, wraps [`eprintln`].
|
||||||
///
|
///
|
||||||
/// There are essentially two different versions of the `info!()` macro:
|
/// There are essentially two different versions of the `info!()` macro:
|
||||||
@ -19,24 +21,32 @@ macro_rules! info {
|
|||||||
// Accessible (short/important) info message.
|
// Accessible (short/important) info message.
|
||||||
// Show info message even in ACCESSIBLE mode
|
// Show info message even in ACCESSIBLE mode
|
||||||
(accessible, $($arg:tt)*) => {{
|
(accessible, $($arg:tt)*) => {{
|
||||||
use $crate::utils::colors::{YELLOW, RESET};
|
use ::std::io::{stderr, Write};
|
||||||
|
|
||||||
|
use $crate::{macros::stderr_check, utils::colors::{YELLOW, RESET}};
|
||||||
|
|
||||||
|
let mut stderr = stderr().lock();
|
||||||
|
|
||||||
if $crate::accessible::is_running_in_accessible_mode() {
|
if $crate::accessible::is_running_in_accessible_mode() {
|
||||||
eprint!("{}Info:{} ", *YELLOW, *RESET);
|
stderr_check(write!(stderr, "{}Info:{} ", *YELLOW, *RESET));
|
||||||
} else {
|
} else {
|
||||||
eprint!("{}[INFO]{} ", *YELLOW, *RESET);
|
stderr_check(write!(stderr, "{}[INFO]{} ", *YELLOW, *RESET));
|
||||||
}
|
}
|
||||||
|
|
||||||
eprintln!($($arg)*);
|
stderr_check(writeln!(stderr, $($arg)*));
|
||||||
}};
|
}};
|
||||||
// Inccessible (long/no important) info message.
|
// Inccessible (long/no important) info message.
|
||||||
// Print info message if ACCESSIBLE is not turned on
|
// Print info message if ACCESSIBLE is not turned on
|
||||||
(inaccessible, $($arg:tt)*) => {{
|
(inaccessible, $($arg:tt)*) => {{
|
||||||
use $crate::utils::colors::{YELLOW, RESET};
|
use ::std::io::{stderr, Write};
|
||||||
|
|
||||||
|
use $crate::{macros::stderr_check, utils::colors::{YELLOW, RESET}};
|
||||||
|
|
||||||
|
let mut stderr = stderr().lock();
|
||||||
|
|
||||||
if !$crate::accessible::is_running_in_accessible_mode() {
|
if !$crate::accessible::is_running_in_accessible_mode() {
|
||||||
eprint!("{}[INFO]{} ", *YELLOW, *RESET);
|
stderr_check(write!(stderr, "{}[INFO]{} ", *YELLOW, *RESET));
|
||||||
eprintln!($($arg)*);
|
stderr_check(writeln!(stderr, $($arg)*));
|
||||||
}
|
}
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
@ -45,14 +55,22 @@ macro_rules! info {
|
|||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! warning {
|
macro_rules! warning {
|
||||||
($($arg:tt)*) => {{
|
($($arg:tt)*) => {{
|
||||||
use $crate::utils::colors::{ORANGE, RESET};
|
use ::std::io::{stderr, Write};
|
||||||
|
|
||||||
|
use $crate::{macros::stderr_check, utils::colors::{ORANGE, RESET}};
|
||||||
|
|
||||||
|
let mut stderr = stderr().lock();
|
||||||
|
|
||||||
if $crate::accessible::is_running_in_accessible_mode() {
|
if $crate::accessible::is_running_in_accessible_mode() {
|
||||||
eprint!("{}Warning:{} ", *ORANGE, *RESET);
|
stderr_check(write!(stderr, "{}Warning:{} ", *ORANGE, *RESET));
|
||||||
} else {
|
} else {
|
||||||
eprint!("{}[WARNING]{} ", *ORANGE, *RESET);
|
stderr_check(write!(stderr, "{}[WARNING]{} ", *ORANGE, *RESET));
|
||||||
}
|
}
|
||||||
|
|
||||||
eprintln!($($arg)*);
|
stderr_check(writeln!(stderr, $($arg)*));
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn stderr_check(result: io::Result<()>) {
|
||||||
|
result.expect("failed printing to stderr");
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user