mirror of
				https://github.com/django/daphne.git
				synced 2025-11-04 01:27:33 +03:00 
			
		
		
		
	
						commit
						bfce80a062
					
				| 
						 | 
					@ -113,12 +113,12 @@ class CommandLineInterface(object):
 | 
				
			||||||
        args = self.parser.parse_args(args)
 | 
					        args = self.parser.parse_args(args)
 | 
				
			||||||
        # Set up logging
 | 
					        # Set up logging
 | 
				
			||||||
        logging.basicConfig(
 | 
					        logging.basicConfig(
 | 
				
			||||||
            level = {
 | 
					            level={
 | 
				
			||||||
                0: logging.WARN,
 | 
					                0: logging.WARN,
 | 
				
			||||||
                1: logging.INFO,
 | 
					                1: logging.INFO,
 | 
				
			||||||
                2: logging.DEBUG,
 | 
					                2: logging.DEBUG,
 | 
				
			||||||
            }[args.verbosity],
 | 
					            }[args.verbosity],
 | 
				
			||||||
            format = "%(asctime)-15s %(levelname)-8s %(message)s" ,
 | 
					            format="%(asctime)-15s %(levelname)-8s %(message)s",
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        # If verbosity is 1 or greater, or they told us explicitly, set up access log
 | 
					        # If verbosity is 1 or greater, or they told us explicitly, set up access log
 | 
				
			||||||
        access_log_stream = None
 | 
					        access_log_stream = None
 | 
				
			||||||
| 
						 | 
					@ -153,4 +153,5 @@ class CommandLineInterface(object):
 | 
				
			||||||
            action_logger=AccessLogGenerator(access_log_stream) if access_log_stream else None,
 | 
					            action_logger=AccessLogGenerator(access_log_stream) if access_log_stream else None,
 | 
				
			||||||
            ws_protocols=args.ws_protocols,
 | 
					            ws_protocols=args.ws_protocols,
 | 
				
			||||||
            root_path=args.root_path,
 | 
					            root_path=args.root_path,
 | 
				
			||||||
 | 
					            verbosity=args.verbosity,
 | 
				
			||||||
        ).run()
 | 
					        ).run()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2,7 +2,7 @@ import logging
 | 
				
			||||||
import socket
 | 
					import socket
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from twisted.internet import reactor, defer
 | 
					from twisted.internet import reactor, defer
 | 
				
			||||||
from twisted.logger import globalLogBeginner
 | 
					from twisted.logger import globalLogBeginner, STDLibLogObserver
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from .http_protocol import HTTPFactory
 | 
					from .http_protocol import HTTPFactory
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -26,6 +26,7 @@ class Server(object):
 | 
				
			||||||
        ping_timeout=30,
 | 
					        ping_timeout=30,
 | 
				
			||||||
        ws_protocols=None,
 | 
					        ws_protocols=None,
 | 
				
			||||||
        root_path="",
 | 
					        root_path="",
 | 
				
			||||||
 | 
					        verbosity=None
 | 
				
			||||||
    ):
 | 
					    ):
 | 
				
			||||||
        self.channel_layer = channel_layer
 | 
					        self.channel_layer = channel_layer
 | 
				
			||||||
        self.host = host
 | 
					        self.host = host
 | 
				
			||||||
| 
						 | 
					@ -42,6 +43,7 @@ class Server(object):
 | 
				
			||||||
        self.websocket_timeout = websocket_timeout or getattr(channel_layer, "group_expiry", 86400)
 | 
					        self.websocket_timeout = websocket_timeout or getattr(channel_layer, "group_expiry", 86400)
 | 
				
			||||||
        self.ws_protocols = ws_protocols
 | 
					        self.ws_protocols = ws_protocols
 | 
				
			||||||
        self.root_path = root_path
 | 
					        self.root_path = root_path
 | 
				
			||||||
 | 
					        self.verbosity = verbosity
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def run(self):
 | 
					    def run(self):
 | 
				
			||||||
        self.factory = HTTPFactory(
 | 
					        self.factory = HTTPFactory(
 | 
				
			||||||
| 
						 | 
					@ -54,8 +56,11 @@ class Server(object):
 | 
				
			||||||
            ws_protocols=self.ws_protocols,
 | 
					            ws_protocols=self.ws_protocols,
 | 
				
			||||||
            root_path=self.root_path,
 | 
					            root_path=self.root_path,
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        # Redirect the Twisted log to nowhere
 | 
					        if self.verbosity <= 1:
 | 
				
			||||||
        globalLogBeginner.beginLoggingTo([lambda _: None], redirectStandardIO=False, discardBuffer=True)
 | 
					            # Redirect the Twisted log to nowhere
 | 
				
			||||||
 | 
					            globalLogBeginner.beginLoggingTo([lambda _: None], redirectStandardIO=False, discardBuffer=True)
 | 
				
			||||||
 | 
					        else:
 | 
				
			||||||
 | 
					            globalLogBeginner.beginLoggingTo([STDLibLogObserver(__name__)])
 | 
				
			||||||
        # Listen on a socket
 | 
					        # Listen on a socket
 | 
				
			||||||
        if self.unix_socket:
 | 
					        if self.unix_socket:
 | 
				
			||||||
            reactor.listenUNIX(self.unix_socket, self.factory)
 | 
					            reactor.listenUNIX(self.unix_socket, self.factory)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user