set up logging in a "middleware" rather than on module load