logging rewritten