summary refs log tree commit diff stats
path: root/rust/semi-structured-logs/src
diff options
context:
space:
mode:
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)
+}