Skip to content

Conversation

@fooooooooooooooo
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant