From ae78af62b9bf9f468a2048e620baef9b441e384e Mon Sep 17 00:00:00 2001 From: uname <529149237@qq.com> Date: Wed, 18 Nov 2015 14:51:24 +0800 Subject: [PATCH] up --- config.py | 4 ++-- genexe.py | 2 +- log.py | 27 ++++++++++++++++++--------- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/config.py b/config.py index 387f42a..ebbacc6 100644 --- a/config.py +++ b/config.py @@ -1,5 +1,5 @@ #-*- coding: utf-8 -*- -RELEASE_TYPE = "py" +RELEASE_TYPE = "release" GITHUB_HOME = "https://github.com/uname/PySockDebuger" TCP_SERVER_ENTRY_TEXT = u"TCP Server" TCP_CLIENT_ENTRY_TEXT = u"TCP Client" @@ -46,4 +46,4 @@ STATUS_NOT_CONNECTED = u'未连接' STATUS_DISCONNECTED = u'已断开' STATUS_UDP = u'UDP-CLIENT' -STATUS_UDP_SERVER = u'UDP-SERVER' \ No newline at end of file +STATUS_UDP_SERVER = u'UDP-SERVER' diff --git a/genexe.py b/genexe.py index 357b9c3..b21b801 100644 --- a/genexe.py +++ b/genexe.py @@ -4,6 +4,6 @@ setup( zipfile=None, windows=[{"script":"main.py", "icon_resources":[(1, "resource/icons/app/logo1.ico")]}], - options={"py2exe":{"compressed":2, "bundle_files":3, + options={"py2exe":{"compressed":2, "bundle_files":1, "includes":["sip", "PyQt4.QtGui", "PyQt4.QtCore"], "dll_excludes": ["msvcm90.dll", "msvcp90.dll", "msvcr90.dll"] }}) diff --git a/log.py b/log.py index fb07f32..59dcd22 100644 --- a/log.py +++ b/log.py @@ -3,16 +3,25 @@ import logging import sys -logger = logging.getLogger("root") -__formatter = logging.Formatter("[%(levelname)-7s][%(asctime)s][%(filename)s:%(lineno)d] %(message)s", "%d %b %Y %H:%M:%S") +logger = None -if config.RELEASE_TYPE == "py": +if config.RELEASE_TYPE != "debug": + class __NullLogger: + def debug(self, msg=""): pass + def warning(self, msg=""): pass + def info(self, msg=""): pass + def error(self, msg=""): pass + def fatal(self, msg=""): pass + + logger = __NullLogger() + +else: + logger = logging.getLogger("root") + __formatter = logging.Formatter("[%(levelname)-7s][%(asctime)s][%(filename)s:%(lineno)d] %(message)s", "%d %b %Y %H:%M:%S") __streamHandler = logging.StreamHandler(sys.stdout) __streamHandler.setFormatter(__formatter) logger.addHandler(__streamHandler) - -__fileHandler = logging.FileHandler("debug.log") -__fileHandler.setFormatter(__formatter) -logger.addHandler(__fileHandler) - -logger.setLevel(logging.DEBUG) + __fileHandler = logging.FileHandler("debug.log") + __fileHandler.setFormatter(__formatter) + logger.addHandler(__fileHandler) + logger.setLevel(logging.DEBUG)