update log function from https://gist.github.com/bgrins/5108712