rewrite logging function