fixed segfault when home directory doesn't exist

This is fix for #270.

First segfault was when ``_create_directories()`` called ``log_msg()`` before initialization of logging subsystem. Second segfault was in ``log_close()`` when ``logp`` is NULL.