Put log printing to a function