Custom log handler