-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Keep secure index consistent and include in startup validations
- Loading branch information
1 parent
9c3f601
commit 3c78473
Showing
14 changed files
with
207 additions
and
40 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
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,31 @@ | ||
#[allow(dead_code)] | ||
pub struct Format { | ||
pub bold: &'static str, | ||
pub underline: &'static str, | ||
pub italic: &'static str, | ||
} | ||
|
||
pub struct Colors { | ||
pub green: &'static str, | ||
pub yellow: &'static str, | ||
pub red: &'static str, | ||
pub end: &'static str, | ||
pub light_green: &'static str, | ||
} | ||
|
||
#[allow(dead_code)] | ||
pub fn format() -> Format { | ||
let bold = "\x1B[1m"; | ||
let underline = "\x1B[4m"; | ||
let italic = "\x1B[3m"; | ||
Format { bold, underline, italic } | ||
} | ||
|
||
pub fn colors() -> Colors { | ||
let green = "\x1B[92m"; | ||
let yellow = "\x1B[93m"; | ||
let red = "\x1B[91m"; | ||
let end = "\x1B[0m"; | ||
let light_green = "\x1B[32m"; | ||
Colors { green, yellow, red, end, light_green } | ||
} |
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,40 @@ | ||
use chrono::{Local, Utc}; | ||
use crate::echo::display; | ||
|
||
fn get_time(utc: bool) -> String { | ||
if utc { | ||
Utc::now().to_rfc3339_opts(chrono::SecondsFormat::Secs, true) | ||
} else { | ||
Local::now().to_rfc3339_opts(chrono::SecondsFormat::Secs, true) | ||
} | ||
} | ||
|
||
#[allow(dead_code)] | ||
pub fn debug_func(msg: &str, utc: bool) { | ||
let colors = display::colors(); | ||
println!("[{} {}DEBUG{} {}] {}", get_time(utc), colors.light_green, colors.end, env!("CARGO_CRATE_NAME"), msg) | ||
} | ||
|
||
pub fn info_func(msg: &str, utc: bool) { | ||
let colors = display::colors(); | ||
println!("[{} {}INFO{} {}] {}", get_time(utc), colors.green, colors.end, env!("CARGO_CRATE_NAME"), msg) | ||
} | ||
|
||
#[allow(dead_code)] | ||
pub fn warn_func(msg: &str, utc: bool) { | ||
let colors = display::colors(); | ||
println!("[{} {}WARN{} {}] {}", get_time(utc), colors.yellow, colors.end, env!("CARGO_CRATE_NAME"), msg) | ||
} | ||
|
||
#[allow(dead_code)] | ||
pub fn error_func(msg: &str, utc: bool) { | ||
let colors = display::colors(); | ||
println!("[{} {}ERROR{} {}] {}", get_time(utc), colors.red, colors.end, env!("CARGO_CRATE_NAME"), msg) | ||
} | ||
|
||
#[allow(dead_code)] | ||
pub fn critical_func(msg: &str, utc: bool) { | ||
let colors = display::colors(); | ||
let format = display::format(); | ||
println!("[{} {}{}CRITICAL{} {}] {}", get_time(utc), format.bold, colors.red, colors.end, env!("CARGO_CRATE_NAME"), msg) | ||
} |
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,49 @@ | ||
#[macro_export] | ||
macro_rules! debug { | ||
($msg:expr) => { | ||
$crate::echo::functions::debug_func($msg, false) | ||
}; | ||
($msg:expr, $flag:expr) => { | ||
$crate::echo::functions::debug_func($msg, $flag) | ||
}; | ||
} | ||
|
||
#[macro_export] | ||
macro_rules! info { | ||
($msg:expr) => { | ||
$crate::echo::functions::info_func($msg, false) | ||
}; | ||
($msg:expr, $flag:expr) => { | ||
$crate::echo::functions::info_func($msg, $flag) | ||
}; | ||
} | ||
|
||
#[macro_export] | ||
macro_rules! warn { | ||
($msg:expr) => { | ||
$crate::echo::functions::warn_func($msg, false) | ||
}; | ||
($msg:expr, $flag:expr) => { | ||
$crate::echo::functions::warn_func($msg, $flag) | ||
}; | ||
} | ||
|
||
#[macro_export] | ||
macro_rules! error { | ||
($msg:expr) => { | ||
$crate::echo::functions::error_func($msg, false) | ||
}; | ||
($msg:expr, $flag:expr) => { | ||
$crate::echo::functions::error_func($msg, $flag) | ||
}; | ||
} | ||
|
||
#[macro_export] | ||
macro_rules! critical { | ||
($msg:expr) => { | ||
$crate::echo::functions::critical_func($msg, false) | ||
}; | ||
($msg:expr, $flag:expr) => { | ||
$crate::echo::functions::critical_func($msg, $flag) | ||
}; | ||
} |
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,5 @@ | ||
pub mod functions; | ||
|
||
#[macro_use] | ||
pub mod macros; | ||
pub mod display; |
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
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
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