diff --git a/sanic/mixins/runner.py b/sanic/mixins/runner.py index 30645b2b1d..4160debd55 100644 --- a/sanic/mixins/runner.py +++ b/sanic/mixins/runner.py @@ -424,12 +424,15 @@ def _helper( self.motd(self.serve_location) - if sys.stdout and sys.stdout.isatty() and not self.state.is_debug: - error_logger.warning( - f"{Colors.YELLOW}Sanic is running in PRODUCTION mode. " - "Consider using '--debug' or '--dev' while actively " - f"developing your application.{Colors.END}" + if not self.state.is_debug: + message = ( + "Sanic is running in PRODUCTION mode. Consider using " + "'--debug' or '--dev' while actively developing your " + "application." ) + if sys.stdout and sys.stdout.isatty(): + message = "".join([Colors.YELLOW, message, Colors.END]) + error_logger.warning(message) # Register start/stop events for event_name, settings_name, reverse in (