Hi everyone!
I think I ight be too dumb for gleam cause I'm already stuck on the first string problem 😦
Instructions
In this exercise you'll be processing log-lines.Each log line is a string formatted as follows: "[<LEVEL>]: <MESSAGE>".
There are three different log levels:
INFO
WARNING
ERROR
You have three tasks, each of which will take a log line and ask you to do something with it.Implement the message function to return a log line's message:
message("[ERROR]: Invalid operation")
// -> "Invalid operation"
Any leading or trailing white space should be removed:message("[WARNING]: Disk almost full\r\n")
// -> "Disk almost full"
Here's my code:
pub fn message(log_line: String) -> String { case log_line { "[INFO]: " <> message -> string.trim(message) "[WARNING]: " <> message -> string.trim(message) "[ERROR]: " <> message -> string.trim(message) _ -> "Invalid log message" } }
It's not passing all the tests cause it's returning ("[ERROR]: \t Corrupt disk\t \t \r\n") cause trim only removes the rest as long as it's a space it's my understanding, and it's also removing bits that I don't intend to such aslog_levels.reformat("[WARNING]: Decreased performance")
|> should.equal("Decreased performance (warning)") , am I supposed to stack another function here? not sure what the best way to go could be