When I write a stream to a file, Can I treat it like a "FIFO"?
fn log(file: File, message: String) {
file.write(message.as_bytes()).unwrap();
if f.metadata().unwrap().len() > MY_LIMIT {
//discard first some bytes(old logs) of the file
//and make file size under MY_LIMIT
}
}
I'm making a simple logger struct.
It receives messages and writes them to the logger file.
Every time my app starts, it logs welcome messages, logs what the users have done, and logs good bye messages when they terminate the app.
This log file aims to track the error that my app causes when serious bugs occur. I'm planning showing dialog box with the message to prompt the users to send the log file.
But the problem is, without any size limitation, it theoretically expands to the infinite size.