logger: check closed before logging