DEMO making!

This commit is contained in:
沈瑗杰 2021-02-14 19:58:39 +08:00
parent 5f2962c248
commit 602f70ff10
2 changed files with 10 additions and 6 deletions

View File

@ -44,7 +44,7 @@ class Game:
self.client_log_config = self.log_config['client'] self.client_log_config = self.log_config['client']
self.client_logger = logging.getLogger('client') self.client_logger = logging.getLogger('client')
self.client_fmt = logging.Formatter( self.client_fmt = logging.Formatter(
fmt="[%(asctime)s][%(name)s]:[%(levelname)s] %(message)s", fmt=self.client_log_config['fmt'],
datefmt=self.client_log_config['date_fmt']) datefmt=self.client_log_config['date_fmt'])
self.client_stream_handler = logging.StreamHandler() self.client_stream_handler = logging.StreamHandler()
self.client_stream_handler.setLevel(self.client_log_config['level']) self.client_stream_handler.setLevel(self.client_log_config['level'])
@ -54,7 +54,7 @@ class Game:
self.server_log_config = self.log_config['server'] self.server_log_config = self.log_config['server']
self.server_logger = logging.getLogger('server') self.server_logger = logging.getLogger('server')
self.server_fmt = logging.Formatter( self.server_fmt = logging.Formatter(
fmt="[%(asctime)s][%(name)s]:[%(levelname)s] %(message)s", fmt=self.server_log_config['fmt'],
datefmt=self.server_log_config['date_fmt']) datefmt=self.server_log_config['date_fmt'])
self.server_stream_handler = logging.StreamHandler() self.server_stream_handler = logging.StreamHandler()
self.server_stream_handler.setLevel(self.server_log_config['level']) self.server_stream_handler.setLevel(self.server_log_config['level'])
@ -62,8 +62,8 @@ class Game:
self.server_logger.addHandler(self.server_stream_handler) self.server_logger.addHandler(self.server_stream_handler)
# file logger # file logger
self.log_formatter = logging.Formatter( self.log_formatter = logging.Formatter(
fmt="[%(asctime)s][%(name)s]:[%(levelname)s] %(message)s", fmt=self.log_file_config['fmt'],
datefmt=self.log_config['date_fmt']) datefmt=self.log_file_config['date_fmt'])
# client and server # client and server
self.client = client.RenderThread( self.client = client.RenderThread(
self.client_logger, self.dicts, self.lists, net_mode='local') self.client_logger, self.dicts, self.lists, net_mode='local')

View File

@ -2,20 +2,24 @@
'server': { 'server': {
'level': 'DEBUG', 'level': 'DEBUG',
// option: CRITICAL ERROR WARNING INFO DEBUG // option: CRITICAL ERROR WARNING INFO DEBUG
'fmt': '', 'fmt': '[%(asctime)s][%(name)s]:[%(levelname)s] %(message)s',
// format // format of log
'date_fmt': '%Y-%m-%d %H-%M-%S', 'date_fmt': '%Y-%m-%d %H-%M-%S',
// format at https://docs.python.org/zh-cn/3.8/library/time.html#time.strftime // format at https://docs.python.org/zh-cn/3.8/library/time.html#time.strftime
}, },
'client': { 'client': {
'level': 'DEBUG', 'level': 'DEBUG',
// option: CRITICAL ERROR WARNING INFO DEBUG // option: CRITICAL ERROR WARNING INFO DEBUG
'fmt': '[%(asctime)s][%(name)s]:[%(levelname)s] %(message)s',
// format of log
'date_fmt': '%Y-%m-%d %H-%M-%S', 'date_fmt': '%Y-%m-%d %H-%M-%S',
// format at https://docs.python.org/zh-cn/3.8/library/time.html#time.strftime // format at https://docs.python.org/zh-cn/3.8/library/time.html#time.strftime
}, },
'file': { 'file': {
'level': 'DEBUG', 'level': 'DEBUG',
// option: CRITICAL ERROR WARNING INFO DEBUG // option: CRITICAL ERROR WARNING INFO DEBUG
'fmt': '[%(asctime)s][%(name)s]:[%(levelname)s] %(message)s',
// format of log
'date_fmt': '%Y-%m-%d %H-%M-%S', 'date_fmt': '%Y-%m-%d %H-%M-%S',
// format at https://docs.python.org/zh-cn/3.8/library/time.html#time.strftime // format at https://docs.python.org/zh-cn/3.8/library/time.html#time.strftime
'filename': { 'filename': {