In this exercise you'll be processing log entries.
Each log line is a string formatted as follows: "[<LEVEL>]: <MESSAGE>".
There are three different log levels:
INFOWARNINGERRORYou have three tasks, each of which will take a log line and ask you to do something with it. There are lots of ways to solve these tasks - choose your favourite techniques from the examples above and see what you can come up with.
Implement the message function to return a log line's message:
"[ERROR]: Invalid operation" | message
# => "Invalid operation"Any leading or trailing white space should be removed:
"[WARNING]: Disk almost full\r\n" | message
# => "Disk almost full"Implement the log_level function to return a log line's log level, which should be returned in lowercase:
"[ERROR]: Invalid operation" | log_level
# => "error"Implement the reformat function that reformats the log line, putting the message first and the log level after it in parentheses:
"[INFO]: Operation completed" | reformat
# => "Operation completed (info)"In this exercise you'll be processing log entries.
Each log line is a string formatted as follows: "[<LEVEL>]: <MESSAGE>".
There are three different log levels:
INFOWARNINGERRORYou have three tasks, each of which will take a log line and ask you to do something with it. There are lots of ways to solve these tasks - choose your favourite techniques from the examples above and see what you can come up with.
Implement the message function to return a log line's message:
"[ERROR]: Invalid operation" | message
# => "Invalid operation"Any leading or trailing white space should be removed:
"[WARNING]: Disk almost full\r\n" | message
# => "Disk almost full"Implement the log_level function to return a log line's log level, which should be returned in lowercase:
"[ERROR]: Invalid operation" | log_level
# => "error"Implement the reformat function that reformats the log line, putting the message first and the log level after it in parentheses:
"[INFO]: Operation completed" | reformat
# => "Operation completed (info)"