Better logger implementation (credit: @samwho)