This commit is contained in:
沈瑗杰 2021-02-15 21:45:20 +08:00
parent 496ccb0580
commit dfeb573d4c
5 changed files with 29 additions and 21 deletions

View File

@ -4,7 +4,7 @@
0.0 (developing) 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 > It's a Simple Rocket liked game build with Python

View File

@ -54,16 +54,13 @@ class RenderThread(mp.Process, pyglet.window.Window):
self.planet_system = tools.config('sys_value/planet.json5') # hole planet system self.planet_system = tools.config('sys_value/planet.json5') # hole planet system
# list # list
# re stuff # 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 # window
self.window = Window(width=int(self.window_config['width']), self.window = Window(width=int(self.window_config['width']),
height=int(self.window_config['height']), height=int(self.window_config['height']),
fullscreen=tools.c_b( fullscreen=tools.c_b(self.window_config['full_screen']),
self.window_config['full_screen']),
caption=str(self.window_config['caption']), caption=str(self.window_config['caption']),
visible=tools.c_b(self.window_config['visible'])) visible=tools.c_b(self.window_config['visible']))
self.logger.info('setup done') self.logger.info('client setup done!')
# setup # setup
self.setup() self.setup()
@ -76,8 +73,8 @@ class RenderThread(mp.Process, pyglet.window.Window):
if self.net_mode == 'local': if self.net_mode == 'local':
pass pass
# net_mode != 'local' and ,can is a ipv4 ip # net_mode != 'local' and ,can is a ipv4 ip
elif re.match(self.ipv4_re, self.net_mode): # elif re.match(self.ipv4_re, self.net_mode):
pass # pass
# textures # textures
self.textures = {} self.textures = {}
# parts # parts

View File

@ -33,16 +33,26 @@ class Game:
self.lists = share().list() self.lists = share().list()
# logger # logger
self.log_config = tools.config('configs/logging.json5', 'file') self.log_config = tools.config('configs/logging.json5', 'file')
self.log_filename = 'logs/' + configs.name_handler( self.log_filename = 'logs/' + configs.name_handler(self.log_config['filename']['main'],
self.log_config['filename']['main'], self.log_config['filename']['formats']) self.log_config['filename']['formats'])
logging.basicConfig(filename=self.log_filename, level=logging.DEBUG) logging.basicConfig(level=logging.DEBUG,
self.root_logger_stream_hander = logging.StreamHandler() format=self.log_config['fmt'],
self.root_logger_stream_hander.setLevel( datefmt=self.log_config['date_fmt'])
self.log_config['level']) self.root_logger_stream_handler = logging.StreamHandler()
logging.getLogger().addHandler(self.root_logger_stream_hander) self.root_logger_stream_handler.setLevel(self.log_config['level'])
logging.info('logger done') 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') self.client_logger.info('client logger and server logger done')
# client and server # client and server
self.client = client.RenderThread( self.client = client.RenderThread(

View File

@ -18,6 +18,7 @@ class server(mp.Process):
# share memory # share memory
self.dev_list = dev_list self.dev_list = dev_list
self.dev_dic = dev_dic self.dev_dic = dev_dic
self.logger.info('server setup done!')
def run(self): def run(self):
pass pass

View File

@ -23,12 +23,12 @@
'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': {
'main': '{date} SR.log', 'main': '{date} DR.log',
// {date} -> date // {date} -> date
'formats': { 'formats': {
'{date}': '%Y-%m-%d %H-%M-%S', '{date}': '%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
// can and more {xx} by adding more obj EZ // can and more {xx} by adding more obj EZ
} }
} }
} }