Skip to content

Commit

Permalink
Fixed issue with previous commit
Browse files Browse the repository at this point in the history
  • Loading branch information
javachaos committed Mar 25, 2024
1 parent a3433d0 commit c734589
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ pub enum LineEnding {
/// Carriage return
CR,
/// Carriage return + Line feed
CRLF,
Crlf,
/// Vertical tab
VT,
/// Form feed
FF,
/// Next line
NEL,
Nel,
/// Line separator
LS,
/// Paragraph separator
Expand Down Expand Up @@ -142,14 +142,15 @@ impl ConfigBuilder {
ConfigBuilder(Config::default())
}

/// Set a custom line ending
pub fn set_line_ending(&mut self, line_ending: LineEnding) -> &mut ConfigBuilder {
match line_ending {
LineEnding::LF => self.0.line_ending = String::from("\u{000A}"),
LineEnding::CR => self.0.line_ending = String::from("\u{000D}"),
LineEnding::CRLF => self.0.line_ending = String::from("\u{000D}\u{000A}"),
LineEnding::Crlf => self.0.line_ending = String::from("\u{000D}\u{000A}"),
LineEnding::VT => self.0.line_ending = String::from("\u{000B}"),
LineEnding::FF => self.0.line_ending = String::from("\u{000C}"),
LineEnding::NEL => self.0.line_ending = String::from("\u{0085}"),
LineEnding::Nel => self.0.line_ending = String::from("\u{0085}"),
LineEnding::LS => self.0.line_ending = String::from("\u{2028}"),
LineEnding::PS => self.0.line_ending = String::from("\u{2029}"),
}
Expand Down Expand Up @@ -403,7 +404,7 @@ impl Default for Config {

#[cfg(feature = "paris")]
enable_paris_formatting: true,
line_ending: '\n'
line_ending: String::from("\u{000A}"),
}
}
}
2 changes: 1 addition & 1 deletion src/loggers/termlog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ impl TermLogger {
#[cfg(feature = "paris")]
write_args(record, term_lock, self.config.enable_paris_formatting)?;
#[cfg(not(feature = "paris"))]
write_args(record, term_lock)?;
write_args(record, term_lock, &self.config.line_ending)?;

// The log crate holds the logger as a `static mut`, which isn't dropped
// at program exit: https://doc.rust-lang.org/reference/items/static-items.html
Expand Down

0 comments on commit c734589

Please sign in to comment.