Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add first and final line separators #7

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

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