Skip to content

Commit

Permalink
upgrade to 0.2.8
Browse files Browse the repository at this point in the history
  • Loading branch information
donnie4w committed Dec 12, 2024
1 parent 681eb69 commit 226fede
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

```rust
[dependencies]
tklog = "0.2.7" # "0.x.x" current version
tklog = "0.2.8" # "0.x.x" current version
```

The simplest way to use tklog involves direct macro calls:
Expand Down Expand Up @@ -769,14 +769,9 @@ fn testlog() {
(now.format("%Y/%m/%d").to_string(), now.format("%H:%M:%S").to_string(), "".to_string())
});


fmt.set_body_fmt(|level, body| {
//Handles the last newline character of the body
let trimmed_body = if body.ends_with('\n') {
format!("{}{}", body.as_str()[..body.len() - 1].to_string(), "\x1b[0m\n")
} else {
format!("{}{}", body, "\x1b[0m\n")
};
fmt.set_console_body_fmt(|level, body| {
//Handles the last newline character of the body
let trimmed_body = if body.ends_with('\n') { format!("{}{}", body.as_str()[..body.len() - 1].to_string(), "\x1b[0m\n") } else { format!("{}{}", body, "\x1b[0m\n") };

match level {
LEVEL::Trace => format!("{}{}", "\x1b[34m", trimmed_body), //blue
Expand All @@ -788,6 +783,20 @@ fn testlog() {
LEVEL::Off => "".to_string(),
}
});

fmt.set_body_fmt(|level, body| {
//Handles the last newline character of the body
let trimmed_body = if body.ends_with('\n') { format!("{}{}", body.as_str()[..body.len() - 1].to_string(), "\x1b[0m\n") } else { format!("{}{}", body, "\x1b[0m\n") };
match level {
LEVEL::Trace => format!("{}{}", "\x1b[44m", trimmed_body), //background blue
LEVEL::Debug => format!("{}{}", "\x1b[46m", trimmed_body), //background cyan
LEVEL::Info => format!("{}{}", "\x1b[42m", trimmed_body), //background green
LEVEL::Warn => format!("{}{}", "\x1b[43m", trimmed_body), //background yellow
LEVEL::Error => format!("{}{}", "\x1b[41m", trimmed_body), //background red
LEVEL::Fatal => format!("{}{}", "\x1b[45m", trimmed_body), //background purple
LEVEL::Off => "".to_string(),
}
});
});

trace!("trace!", "this is sync log");
Expand Down

0 comments on commit 226fede

Please sign in to comment.