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 LogLineParser.message
method to return a log line's message:
LogLineParser.message('[ERROR]: Invalid operation')
// Returns: "Invalid operation"
Any leading or trailing white space should be removed:
LogLineParser.message('[WARNING]: Disk almost full\r\n')
// Returns: "Disk almost full"
Implement the LogLineParser.log_level
method to return a log line's log level, which should be returned in lowercase:
LogLineParser.log_level('[ERROR]: Invalid operation')
// Returns: "error"
Implement the LogLineParser.reformat
method that reformats the log line, putting the message first and the log level after it in parentheses:
LogLineParser.reformat('[INFO]: Operation completed')
// Returns: "Operation completed (info)"