rust-colog icon indicating copy to clipboard operation
rust-colog copied to clipboard

add first and final line separators

Open fooooooooooooooo opened this issue 1 year ago • 0 comments

adds the ability to have a specific line separator on first and last lines and also pads single line messages to align with the first line separator

no doc comments on the functions i added as i did this for my personal use, but i can write some if you wish to merge this pr

example usage:

pub struct LogStyle;

impl CologStyle for LogStyle {
  fn level_token(&self, level: &Level) -> &str {
    match level {
      Level::Trace => "TRC",
      Level::Debug => "DBG",
      Level::Info => "INF",
      Level::Warn => "WRN",
      Level::Error => "ERR",
    }
  }

  fn prefix_token(&self, level: &Level) -> String {
    self.level_color(level, self.level_token(level))
  }

  fn first_line_separator(&self) -> String {
    "╭ ".to_string()
  }

  fn line_separator(&self) -> String {
    "\n│     ".to_string()
  }

  fn final_line_separator(&self) -> String {
    "\n╰     ".to_string()
  }
}
  ERR error message
  ERR error with fmt: 42
  WRN warn message
  INF info message
  DBG debug message
  TRC trace message
╭ INF multi line demonstration
╰     here
╭ INF more
│     multi
│     line
│     here
╰     here

fooooooooooooooo avatar Oct 26 '24 16:10 fooooooooooooooo