added logging function based on environment var