优化日志打印
diff --git a/dubbo/client.py b/dubbo/client.py
index 74afee3..279f7ff 100644
--- a/dubbo/client.py
+++ b/dubbo/client.py
@@ -12,7 +12,7 @@
from dubbo.common.util import parse_url, get_pid, get_ip
from dubbo.connection.connections import connection_pool
-logger = logging.getLogger('dubbo')
+logger = logging.getLogger('python-dubbo')
class DubboClient(object):
diff --git a/dubbo/common/loggers.py b/dubbo/common/loggers.py
index ead29a9..23befc1 100644
--- a/dubbo/common/loggers.py
+++ b/dubbo/common/loggers.py
@@ -40,7 +40,7 @@
初始化dubbo的日志配置
:return:
"""
- logger = logging.getLogger('dubbo')
+ logger = logging.getLogger('python-dubbo')
console_handler = logging.StreamHandler(sys.stdout)
formatter = MyFormatter(
'%(asctime)s %(levelname)s \033[35m%(process)-5d\033[0m --- [%(threadName)15s] \033[33m%(lineno)-4d\033[0m \033[36m%(filename)s\033[0m: %(message)s')
diff --git a/dubbo/common/util.py b/dubbo/common/util.py
index 60cbd23..5fc0ab5 100644
--- a/dubbo/common/util.py
+++ b/dubbo/common/util.py
@@ -8,7 +8,7 @@
import logging
-logger = logging.getLogger('dubbo')
+logger = logging.getLogger('python-dubbo')
ip = None
heartbeat_id = 0
diff --git a/dubbo/connection/connections.py b/dubbo/connection/connections.py
index 0e40a77..9e5a70a 100644
--- a/dubbo/connection/connections.py
+++ b/dubbo/connection/connections.py
@@ -13,7 +13,7 @@
from dubbo.common.exceptions import DubboResponseException, DubboRequestTimeoutException
from dubbo.common.util import get_invoke_id
-logger = logging.getLogger('dubbo')
+logger = logging.getLogger('python-dubbo')
class BaseConnectionPool(object):
@@ -65,6 +65,7 @@
result = self.results.pop(invoke_id)
if isinstance(result, Exception):
logger.exception(result)
+ logger.error('Exception {} for host {}'.format(result, host))
raise result
return result
@@ -261,9 +262,8 @@
if self.client_heartbeats[host] >= TIMEOUT_MAX_TIMES:
self._new_connection(host)
self.client_heartbeats[host] = 0
- logger.debug('{} timeout and reconnected by client'.format(host))
- # 关闭旧的连接
- conn.close()
+ conn.close() # 关闭旧的连接
+ logger.debug('{} timeout and reconnected by client.'.format(host))
# 未达到最大的超时次数,超时次数+1且发送心跳包
else:
@@ -382,6 +382,7 @@
关闭连接
:return:
"""
+ logger.debug('{} closed by client.'.format(self.__host))
self.__sock.shutdown(socket.SHUT_RDWR)
self.__sock.close()
diff --git a/tests/dubbo_test.py b/tests/dubbo_test.py
index 0859cca..9611fa4 100644
--- a/tests/dubbo_test.py
+++ b/tests/dubbo_test.py
@@ -9,7 +9,7 @@
from dubbo.common.exceptions import DubboException
from dubbo.client import DubboClient, ZkRegister
-logger = logging.getLogger('dubbo')
+logger = logging.getLogger('python-dubbo')
def pretty_print(value):
@@ -74,7 +74,7 @@
pretty_print(dubbo.call('echo22'))
pretty_print(dubbo.call('echo23'))
- log = logging.getLogger('dubbo')
+ log = logging.getLogger('python-dubbo')
log.debug('1111')
log.info('22222')