diff --git a/README.md b/README.md index c464422..fb9b422 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ 0.0 (developing) -中文版请移步[这里](https://github.com/shenjackyuanjie/DR/blob/main/docs/README-cn.md)。 +中文README请移步[这里](https://github.com/shenjackyuanjie/Difficult-Rocket/blob/main/docs/README-cn.md)。 > It's a Simple Rocket liked game build with Python diff --git a/bin/client.py b/bin/client.py index 1b16133..bf84a8f 100644 --- a/bin/client.py +++ b/bin/client.py @@ -54,16 +54,13 @@ class RenderThread(mp.Process, pyglet.window.Window): self.planet_system = tools.config('sys_value/planet.json5') # hole planet system # list # re stuff - self.ipv4_re = re.compile( - u'^(25[0-5]|2[0-4]\d|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3}$') # window self.window = Window(width=int(self.window_config['width']), height=int(self.window_config['height']), - fullscreen=tools.c_b( - self.window_config['full_screen']), + fullscreen=tools.c_b(self.window_config['full_screen']), caption=str(self.window_config['caption']), visible=tools.c_b(self.window_config['visible'])) - self.logger.info('setup done') + self.logger.info('client setup done!') # setup self.setup() @@ -76,8 +73,8 @@ class RenderThread(mp.Process, pyglet.window.Window): if self.net_mode == 'local': pass # net_mode != 'local' and ,can is a ipv4 ip - elif re.match(self.ipv4_re, self.net_mode): - pass + # elif re.match(self.ipv4_re, self.net_mode): + # pass # textures self.textures = {} # parts diff --git a/bin/main.py b/bin/main.py index 7c2f5f8..15bda46 100644 --- a/bin/main.py +++ b/bin/main.py @@ -33,16 +33,26 @@ class Game: self.lists = share().list() # logger self.log_config = tools.config('configs/logging.json5', 'file') - self.log_filename = 'logs/' + configs.name_handler( - self.log_config['filename']['main'], self.log_config['filename']['formats']) - logging.basicConfig(filename=self.log_filename, level=logging.DEBUG) - self.root_logger_stream_hander = logging.StreamHandler() - self.root_logger_stream_hander.setLevel( - self.log_config['level']) - logging.getLogger().addHandler(self.root_logger_stream_hander) + self.log_filename = 'logs/' + configs.name_handler(self.log_config['filename']['main'], + self.log_config['filename']['formats']) + logging.basicConfig(level=logging.DEBUG, + format=self.log_config['fmt'], + datefmt=self.log_config['date_fmt']) + self.root_logger_stream_handler = logging.StreamHandler() + self.root_logger_stream_handler.setLevel(self.log_config['level']) + logging.info('logger done') - self.server_logger = logging.getLogger() - self.client_logger = logging.getLogger() + + self.root_logger_fmt = logging.Formatter(self.log_config['fmt'], self.log_config['date_fmt']) + self.root_logger_stream_handler.setFormatter(self.root_logger_fmt) + self.root_logger_stream_handler.setLevel(self.log_config['level']) + self.root_logger_file_handler = logging.FileHandler(self.log_filename) + self.root_logger_file_handler.setFormatter(self.root_logger_fmt) + logging.getLogger().addHandler(self.root_logger_stream_handler) + logging.getLogger().addHandler(self.root_logger_file_handler) + + self.server_logger = logging.getLogger().getChild('server') + self.client_logger = logging.getLogger().getChild('client') self.client_logger.info('client logger and server logger done') # client and server self.client = client.RenderThread( diff --git a/bin/server.py b/bin/server.py index c971f95..d8767b5 100644 --- a/bin/server.py +++ b/bin/server.py @@ -18,6 +18,7 @@ class server(mp.Process): # share memory self.dev_list = dev_list self.dev_dic = dev_dic + self.logger.info('server setup done!') def run(self): pass diff --git a/configs/logging.json5 b/configs/logging.json5 index c6f38ac..a9e6cf2 100644 --- a/configs/logging.json5 +++ b/configs/logging.json5 @@ -23,12 +23,12 @@ 'date_fmt': '%Y-%m-%d %H-%M-%S', // format at https://docs.python.org/zh-cn/3.8/library/time.html#time.strftime 'filename': { - 'main': '{date} SR.log', + 'main': '{date} DR.log', // {date} -> date 'formats': { - '{date}': '%Y-%m-%d %H-%M-%S', - // format at https://docs.python.org/zh-cn/3.8/library/time.html#time.strftime - // can and more {xx} by adding more obj EZ + '{date}': '%Y-%m-%d %H-%M-%S' + // format at https://docs.python.org/zh-cn/3.8/library/time.html#time.strftime + // can and more {xx} by adding more obj EZ } } }