Fix a memory leak in logging

Closes #36