Warning
This post was published 31 days ago. The information described in this article may have changed.
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
if not within a loop; this somehow works as expected
let subscriber = Registry::default().with(xxx).with(yyy);
2 posts - 2 participants
🏷️ rust_feed