Hello, rustaceans.
I am working on a tiny lab and I have a problem about how to disable the logging outputs of specific instances.
Below is the codes.
struct Instace {
members...
}
impl Instance {
fn new() -> Instance {
// spawn some threads to work.
// these threads will produce some logging output.
}
fn kill(&self) {
// disable the logging output of the threads and return immediately.
}
}
fn main() {
let ins1 = Instance::new();
// do some work
ins1.kill();
let ins2 = Instance::new();
// do some work
ins2.kill();
//...
}
The main
function will create many instances and do some work to check if these instances work properly.
After the checking finished, the main
function will call kill()
to disable the logging output of the created instance to avoid the logging outputs of difference instances produced together.
Do you have any ideas about how to implement kill()
?
Any help will be appreciated!