new log mechanism: get_timestamp is now more bullet proof.

Check error code of all C library functions involved.