In this exercise you'll be generating semi-structured log messages.
You'll start with some stubbed functions and the following enum:
#[derive(Clone, PartialEq, Debug)]
pub enum LogLevel {
Info,
Warning,
Error,
}Your goal is to emit a log message as follows: "[<LEVEL>]: <MESSAGE>".
You'll need to implement functions that correspond with log levels.
For example, the below snippet demonstrates an expected output for the log function.
log(LogLevel::Error, "Stack overflow")
// Returns: "[ERROR]: Stack overflow"And for info:
info("Timezone changed")
// Returns: "[INFO]: Timezone changed"Have fun!
There is a feature-gated test in this suite. Feature gates disable compilation entirely for certain sections of your program. They will be covered later. For now just know that there is a test which is only built and run when you use a special testing invocation:
cargo test --features add-a-variantThis test is meant to show you how to add a variant to your enum.
In this exercise you'll be generating semi-structured log messages.
You'll start with some stubbed functions and the following enum:
#[derive(Clone, PartialEq, Debug)]
pub enum LogLevel {
Info,
Warning,
Error,
}Your goal is to emit a log message as follows: "[<LEVEL>]: <MESSAGE>".
You'll need to implement functions that correspond with log levels.
For example, the below snippet demonstrates an expected output for the log function.
log(LogLevel::Error, "Stack overflow")
// Returns: "[ERROR]: Stack overflow"And for info:
info("Timezone changed")
// Returns: "[INFO]: Timezone changed"Have fun!
There is a feature-gated test in this suite. Feature gates disable compilation entirely for certain sections of your program. They will be covered later. For now just know that there is a test which is only built and run when you use a special testing invocation:
cargo test --features add-a-variantThis test is meant to show you how to add a variant to your enum.