fixed loggin middleware