Factoring out log code