File tree Expand file tree Collapse file tree 4 files changed +8
-10
lines changed Expand file tree Collapse file tree 4 files changed +8
-10
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ fn create_formatter(cli: &Cli) -> MessageFormatter {
79
79
} else if cli. no_color {
80
80
false
81
81
} else {
82
- colored:: control:: SHOULD_COLORIZE . should_colorize ( )
82
+ colored:: control:: ShouldColorize :: from_env ( ) . should_colorize ( )
83
83
} ;
84
84
let timestamp_format = cli. timestamp_format . unwrap_or ( {
85
85
if tty {
@@ -209,9 +209,6 @@ async fn main() -> Result<()> {
209
209
// Fix broken pipe panics
210
210
sigpipe:: reset ( ) ;
211
211
212
- // Let us control the coloring instead of colored
213
- colored:: control:: set_override ( true ) ;
214
-
215
212
let config = load_config ( ) ?;
216
213
let database = config
217
214
. as_ref ( )
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ use anyhow::{anyhow, Result};
5
5
use chrono:: { Local , TimeZone , Utc } ;
6
6
use chrono_humanize:: HumanTime ;
7
7
use database:: { Message , State } ;
8
- use std:: collections:: HashMap ;
8
+ use std:: { collections:: HashMap , sync :: Once } ;
9
9
10
10
enum Word {
11
11
Message ,
@@ -103,6 +103,12 @@ impl MessageFormatter {
103
103
pub fn format_message ( & self , message : & Message , appendix : Option < String > ) -> Result < String > {
104
104
use colored:: Colorize ;
105
105
106
+ static INIT : Once = Once :: new ( ) ;
107
+ INIT . call_once ( || {
108
+ // Let us control the coloring instead of colored
109
+ colored:: control:: set_override ( true ) ;
110
+ } ) ;
111
+
106
112
// Display the time differently based on the requested format
107
113
let time = match self . timestamp_format {
108
114
TimestampFormat :: Relative => Some (
Original file line number Diff line number Diff line change @@ -191,7 +191,6 @@ mod tests {
191
191
assert_eq ! ( line. to_string( ) , "⭐⭐…" ) ;
192
192
}
193
193
194
- // This test requires CLICOLOR_FORCE=1 set in .cargo/config.toml to use colors, even in CI
195
194
#[ test]
196
195
fn test_colored ( ) {
197
196
let mut line = TruncatedLine :: new ( 11 ) ;
@@ -200,7 +199,6 @@ mod tests {
200
199
assert_eq ! ( line. to_string( ) , "hello \u{1b} [31mworld\u{1b} [0m" ) ;
201
200
}
202
201
203
- // This test requires CLICOLOR_FORCE=1 set in .cargo/config.toml to use colors, even in CI
204
202
#[ test]
205
203
fn test_colored_empty_string ( ) {
206
204
let mut line = TruncatedLine :: new ( 5 ) ;
You can’t perform that action at this time.
0 commit comments