comparison pytouhou/utils/helpers.py @ 566:04ae31809dc7

Move all logging logic to the root logger, we don’t need specific handlers anymore.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Mon, 30 Jun 2014 20:37:52 +0200
parents 3da4de9decd0
children
comparison
equal deleted inserted replaced
565:5f7f859a72f9 566:04ae31809dc7
10 ## but WITHOUT ANY WARRANTY; without even the implied warranty of 10 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 ## GNU General Public License for more details. 12 ## GNU General Public License for more details.
13 ## 13 ##
14 14
15 15 #TODO: remove that someday.
16 from logging import StreamHandler, Formatter, getLogger 16 from logging import getLogger as get_logger
17
18
19 def get_logger(name):
20 handler = StreamHandler()
21 formatter = Formatter(fmt='[%(name)s] [%(levelname)s]: %(message)s')
22 handler.setFormatter(formatter)
23 logger = getLogger(name)
24 logger.addHandler(handler)
25 logger.propagate = False
26 return logger
27 17
28 18
29 def read_string(file, size, encoding=None): 19 def read_string(file, size, encoding=None):
30 data = file.read(size) 20 data = file.read(size)
31 21