aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs4
-rw-r--r--src/logger_utils.rs10
-rw-r--r--src/macros.rs9
-rw-r--r--src/string_utils.rs16
4 files changed, 32 insertions, 7 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 5d6a463..caab871 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,3 +1,5 @@
pub mod console_utils;
pub mod logger_utils;
-pub mod convert_utils; \ No newline at end of file
+pub mod convert_utils;
+pub mod macros;
+pub mod string_utils; \ No newline at end of file
diff --git a/src/logger_utils.rs b/src/logger_utils.rs
index 77b136e..543b706 100644
--- a/src/logger_utils.rs
+++ b/src/logger_utils.rs
@@ -1,7 +1,7 @@
use env_logger::Builder;
-use log::{info, LevelFilter};
+use log::LevelFilter;
-pub fn logger_build () {
+pub fn logger_build(level: LevelFilter) {
Builder::new()
.format(|buf, record| {
use std::io::Write;
@@ -15,8 +15,6 @@ pub fn logger_build () {
record.args()
)
})
- .filter(None, LevelFilter::Info)
+ .filter(None, level)
.init();
- info!("Logger Built.")
-}
-
+} \ No newline at end of file
diff --git a/src/macros.rs b/src/macros.rs
new file mode 100644
index 0000000..a7f9dd4
--- /dev/null
+++ b/src/macros.rs
@@ -0,0 +1,9 @@
+#[macro_export]
+macro_rules! entry_mutex {
+ ($mutex:expr, |$guard:ident| $code:expr) => {
+ if let Ok(mut $guard) = $mutex.lock() {
+ let $guard = &mut $guard;
+ $code
+ }
+ };
+} \ No newline at end of file
diff --git a/src/string_utils.rs b/src/string_utils.rs
new file mode 100644
index 0000000..7a02f25
--- /dev/null
+++ b/src/string_utils.rs
@@ -0,0 +1,16 @@
+pub fn process_id_text(input: String) -> String {
+ let s = input.trim().to_lowercase();
+ let mut result = String::new();
+
+ for c in s.chars() {
+ match c {
+ '\n' | '_' => continue,
+ '-' | '.' | ',' | ' ' => result.push('_'),
+ _ => result.push(c),
+ }
+ }
+
+ result.chars()
+ .filter(|&c| c.is_ascii_alphanumeric() || c == '_')
+ .collect()
+} \ No newline at end of file