updated logging middleware