I have the following code
// configs is just a struct maintaining the logger / layer's settings
for config in loggers.configs.iter() {
match config.logger_type.as_str() {
// stdout will create a layer to log at std-out simply
"stdout" => {
// the fn returns a Result<Layer<Registry>, std::io::Error>; hence I simply unwrap it
let layer = setup_stdout_logger().unwrap();
// * this failed as
// `subscriber` moved due to this method call, in previous iteration of loop
subscriber.with(layer);
}
"file" => {
let layer = setup_file_logger().unwrap();
// * this doesn't work either as the return data type after with() is
// different (should say incremental)
subscriber = subscriber.with(layer).boxed();
}
_ => {}
}
}
so I could not find a solution on this; need some help
- issue 1 : subscriber.with(xxx) won't work as moved
- issue 2 : re-assignment not work as well since the original subscriber is of another type (Registry) but after calling with() returning Layer<x, y> instead
if not within a loop; this somehow works as expected
let subscriber = Registry::default().with(xxx).with(yyy);