added a statement to make a log directory if necessary - juncheng