-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove need for owo colors and add test cases
- Loading branch information
Showing
8 changed files
with
133 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
/target | ||
/logs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
[ ] Remove owo collors dependency | ||
[x] Remove owo collors dependency | ||
[ ] Make colors a feature flag | ||
[ ] Create test cases | ||
[x] Create test cases | ||
[ ] Extend readme and documentation | ||
[ ] Create better rs doc comments |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
[package] | ||
name = "scorched" | ||
description = "A simple logging library for scorching all those pesky bugs." | ||
version = "0.4.5" | ||
version = "0.5.0" | ||
edition = "2021" | ||
license = "Apache-2.0" | ||
|
||
[dependencies] | ||
owo-colors = "3.5.0" | ||
chrono = "0.4.31" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use crate::{log_this, logf, LogData, LogImportance}; | ||
|
||
#[test] | ||
fn test_log_this() { | ||
log_this(LogData { | ||
importance: LogImportance::Error, | ||
message: "Test error".to_string(), | ||
}); | ||
|
||
log_this(LogData { | ||
importance: LogImportance::Warning, | ||
message: "Test warning".to_string(), | ||
}); | ||
|
||
log_this(LogData { | ||
importance: LogImportance::Info, | ||
message: "Test info".to_string(), | ||
}); | ||
|
||
log_this(LogData { | ||
importance: LogImportance::Debug, | ||
message: "Test debug".to_string(), | ||
}); | ||
} | ||
|
||
#[test] | ||
fn test_logf() { | ||
logf!(Error, "Test error"); | ||
|
||
logf!(Warning, "Test warning"); | ||
|
||
logf!(Info, "Test info"); | ||
|
||
logf!(Debug, "Test debug"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,22 @@ | ||
use owo_colors::{ | ||
colors::{css::*, CustomColor}, | ||
ComboColorDisplay, OwoColorize, | ||
}; | ||
/// This file contains the tags for the different levels of importance. | ||
/// These are pasted in front of the message when logging. | ||
pub(crate) fn error_tag( | ||
) -> ComboColorDisplay<'static, CustomColor<0, 0, 0>, CustomColor<{ u8::MAX }, 0, 0>, &'static str> | ||
{ | ||
"[ERROR]".fg::<Black>().bg::<Red>() | ||
/// Error tag displays red. | ||
pub(crate) const fn error_tag() -> &'static str { | ||
"\x1b[31m[ERROR]\x1b[0m" | ||
} | ||
|
||
pub(crate) fn warning_tag() -> ComboColorDisplay< | ||
'static, | ||
CustomColor<0, 0, 0>, | ||
CustomColor<{ u8::MAX }, { u8::MAX }, 0>, | ||
&'static str, | ||
> { | ||
"[WARNING]".fg::<Black>().bg::<Yellow>() | ||
/// Warning tag displays yellow. | ||
pub(crate) const fn warning_tag() -> &'static str { | ||
"\x1b[33m[WARNING]\x1b[0m" | ||
} | ||
|
||
pub(crate) fn info_tag( | ||
) -> ComboColorDisplay<'static, CustomColor<0, 0, 0>, CustomColor<211, 211, 211>, &'static str> { | ||
"[INFO]".fg::<Black>().bg::<LightGray>() | ||
/// Info tag displays light gray. | ||
pub(crate) const fn info_tag() -> &'static str { | ||
"\x1b[37m[INFO]\x1b[0m" | ||
} | ||
|
||
pub(crate) fn debug_tag() -> ComboColorDisplay< | ||
'static, | ||
CustomColor<0, 0, 0>, | ||
CustomColor<{ u8::MAX }, 0, { u8::MAX }>, | ||
&'static str, | ||
> { | ||
"[DEBUG]".fg::<Black>().bg::<Magenta>() | ||
/// Debug tag displays pink. | ||
pub(crate) const fn debug_tag() -> &'static str { | ||
"\x1b[35m[DEBUG]\x1b[0m" | ||
} |