Fix log directory missing

If the log directory doesn't exist, script fails to run. This change
adds a check for the log directory and creates it if it's missing.