diff --git a/src/waitress/runner.py b/src/waitress/runner.py index c23ca0eb..949fdb9e 100644 --- a/src/waitress/runner.py +++ b/src/waitress/runner.py @@ -16,6 +16,7 @@ import getopt +import logging import os import os.path import re @@ -23,6 +24,7 @@ from waitress import serve from waitress.adjustments import Adjustments +from waitress.utilities import logger HELP = """\ Usage: @@ -260,6 +262,12 @@ def run(argv=sys.argv, _serve=serve): show_help(sys.stderr, name, "Specify one application only") return 1 + # set a default level for the logger only if it hasn't been set explicitly + # note that this level does not override any parent logger levels, + # handlers, etc but without it no log messages are emitted by default + if logger.level == logging.NOTSET: + logger.setLevel(logging.INFO) + try: module, obj_name = match(args[0]) except ValueError as exc: diff --git a/src/waitress/server.py b/src/waitress/server.py index fe7b6da9..55cffe9b 100644 --- a/src/waitress/server.py +++ b/src/waitress/server.py @@ -125,10 +125,11 @@ def create_server( # In this case we have no need to use a MultiSocketServer return last_serv + log_info = last_serv.log_info # Return a class that has a utility function to print out the sockets it's # listening on, and has a .run() function. All of the TcpWSGIServers # registered themselves in the map above. - return MultiSocketServer(map, adj, effective_listen, dispatcher) + return MultiSocketServer(map, adj, effective_listen, dispatcher, log_info) # This class is only ever used if we have multiple listen sockets. It allows @@ -143,11 +144,13 @@ def __init__( adj=None, effective_listen=None, dispatcher=None, + log_info=None, ): self.adj = adj self.map = map self.effective_listen = effective_listen self.task_dispatcher = dispatcher + self.log_info = log_info def print_listen(self, format_str): # pragma: nocover for l in self.effective_listen: @@ -344,7 +347,7 @@ def maintenance(self, now): if (not channel.requests) and channel.last_activity < cutoff: channel.will_close = True - def print_listen(self, format_str): # pragma: nocover + def print_listen(self, format_str): # pragma: no cover self.log_info(format_str.format(self.effective_host, self.effective_port)) def close(self):