Mercurial > touhou
diff pytouhou/utils/helpers.py @ 58:3da4de9decd0
Use logging module
author | Thibaut Girka <thib@sitedethib.com> |
---|---|
date | Tue, 23 Aug 2011 21:01:50 +0200 |
parents | ab826bc29aa2 |
children | 04ae31809dc7 |
line wrap: on
line diff
--- a/pytouhou/utils/helpers.py +++ b/pytouhou/utils/helpers.py @@ -12,6 +12,20 @@ ## GNU General Public License for more details. ## + +from logging import StreamHandler, Formatter, getLogger + + +def get_logger(name): + handler = StreamHandler() + formatter = Formatter(fmt='[%(name)s] [%(levelname)s]: %(message)s') + handler.setFormatter(formatter) + logger = getLogger(name) + logger.addHandler(handler) + logger.propagate = False + return logger + + def read_string(file, size, encoding=None): data = file.read(size) @@ -24,3 +38,4 @@ def read_string(file, size, encoding=Non return data.decode(encoding) else: return data +