added middleware logging logic