in reply to Re: Persistent logging...
in thread Persistent logging...

A related program is www.cronolog.org . You might be able to use a command line like this one instead of writing any code:
cat /dev/ttyS0 | cronolog /logs/serial_data_%Y-%m-%d
The above line will automatically create one log file per day and date-stamp it with the format YYYY-MM-DD .