In this exercise you'll be processing log-lines.
Each log line is a string formatted as follows: "[<LVL>]: <MESSAGE>".
These are the different log levels:
TRC(trace)DBG(debug)INF(info)WRN(warning)ERR(error)FTL(fatal)
You have three tasks.
Define a LogLevel enum that has six elements corresponding to the above log levels.
TraceDebugInfoWarningErrorFatal
Next, implement the (static) LogLine.ParseLogLevel() method to parse the log level of a log line:
LogLine.ParseLogLevel("[INF]: File deleted")
// => LogLevel.InfoUnfortunately, occasionally some log lines have an unknown log level. To gracefully handle these log lines, add an Unknown element to the LogLevel enum which should be returned when parsing an unknown log level:
LogLine.ParseLogLevel("[XYZ]: Overly specific, out of context message")
// => LogLevel.UnknownThe log level of a log line is quite verbose. To reduce the disk space needed to store the log lines, a short format is developed: "[<ENCODED_LEVEL>]:<MESSAGE>".
The encoded log level is a simple mapping of a log level to a number:
Unknown-0Trace-1Debug-2Info-4Warning-5Error-6Fatal-42
Implement the (static) LogLine.OutputForShortLog() method that can output the shortened log line format:
LogLine.OutputForShortLog(LogLevel.Error, "Stack overflow")
// => "6:Stack overflow"