summary refs log tree commit diff stats
path: root/rust/semi-structured-logs/src
diff options
context:
space:
mode:
authorAndinus <andinus@nand.sh>2021-09-29 09:43:51 +0530
committerAndinus <andinus@nand.sh>2021-09-29 09:43:51 +0530
commitd8a4756b35ce3576bc5027e166903610558cfeab (patch)
tree5b49c90e6428fe6914f2e9505d73faa1c80dd978 /rust/semi-structured-logs/src
parent45fab565a31a535324a335fa96df8f010d855b5c (diff)
downloadexercism-d8a4756b35ce3576bc5027e166903610558cfeab.tar.gz
Rust: Semi Structured Logs: Add Solution
Diffstat (limited to 'rust/semi-structured-logs/src')
-rw-r--r--rust/semi-structured-logs/src/lib.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/rust/semi-structured-logs/src/lib.rs b/rust/semi-structured-logs/src/lib.rs
new file mode 100644
index 0000000..4f06874
--- /dev/null
+++ b/rust/semi-structured-logs/src/lib.rs
@@ -0,0 +1,25 @@
+pub enum LogLevel {
+    Info,
+    Warning,
+    Error,
+}
+
+pub fn log(level: LogLevel, message: &str) -> String {
+    match level {
+        LogLevel::Info => info(message),
+        LogLevel::Warning => warn(message),
+        LogLevel::Error => error(message),
+    }
+}
+
+pub fn info(message: &str) -> String {
+    format!("[INFO]: {}", message)
+}
+
+pub fn warn(message: &str) -> String {
+    format!("[WARNING]: {}", message)
+}
+
+pub fn error(message: &str) -> String {
+    format!("[ERROR]: {}", message)
+}