Use gettimeofday(2) instead of time(2) to get log time in milliseconds.