I'm creating a web-server that need log stuff on files and I struggle to found examples to do that the way I want.
Because I'm using tokio, hyper and routerify, I need a better solution than just opening the file every time I want to write something.
I would like to open the file, keep it somewhere and use a simple macro to write like the log crate can provides. But I don't understand where I should create my task, my object and where I should keep it.
Do you rustacean have conceptually answers to that?
Silly question, but why don't you just use the log crate then?
With logging libraries like log and tracing you'll normally initialize logging at the top of your main() function, then that will open the log file and set a global logger that writes to it (e.g. log::set_logger()).