|
7 | 7 | ''' |
8 | 8 |
|
9 | 9 | import time |
10 | | -import logging |
11 | 10 | from collections import deque |
12 | 11 | from tornado.concurrent import Future |
13 | 12 | from tornado.ioloop import IOLoop |
14 | 13 | from pymysql._compat import text_type |
15 | 14 | from .client import Client |
| 15 | +from . import log |
16 | 16 |
|
17 | 17 |
|
18 | 18 | class ConnectionPoolClosedError(Exception): |
@@ -250,7 +250,7 @@ def connection_close_callback(self, connection): |
250 | 250 | self._connections.remove(connection) |
251 | 251 | self._connections_count -= 1 |
252 | 252 | except ValueError: |
253 | | - logging.warning("Close unknown Connection %s.", connection) |
| 253 | + log.get_log().warning("Close unknown Connection %s.", connection) |
254 | 254 | if self._close_future and not self._used_connections and not self._connections: |
255 | 255 | IOLoop.current().add_callback(self._close_future.set_result, None) |
256 | 256 | self._close_future = None |
@@ -299,14 +299,16 @@ def check_idle_connections(self): |
299 | 299 | if now - connection.used_time > (self._wait_connection_timeout * 4) ** 2: |
300 | 300 | connection.do_close() |
301 | 301 | if self._debug_connection_used: |
302 | | - logging.error("Connection used timeout close, used time %.2fs %s %s.\n%s", now - connection.used_time, connection, self, connection.get_last_query_sql()) |
| 302 | + log.get_log().error("Connection used timeout close, used time %.2fs %s %s.\n%s", now - connection.used_time, connection, self, connection.get_last_query_sql()) |
303 | 303 | else: |
304 | | - logging.error("Connection used timeout close, used time %.2fs %s %s.", now - connection.used_time, connection, self) |
| 304 | + log.get_log().error("Connection used timeout close, used time %.2fs %s %s.", now - connection.used_time, connection, self) |
305 | 305 | elif now - connection.used_time > self._wait_connection_timeout ** 2 * 2: |
306 | 306 | if self._debug_connection_used: |
307 | | - logging.warning("Connection maybe not release, used time %.2fs %s %s.\n%s", now - connection.used_time, connection, self, connection.get_last_query_sql()) |
| 307 | + log.get_log().warning("Connection maybe not release, used time %.2fs %s %s.\n%s", now - connection.used_time, connection, self, connection.get_last_query_sql()) |
308 | 308 | else: |
309 | | - logging.warning("Connection maybe not release, used time %.2fs %s %s.", now - connection.used_time, connection, self) |
| 309 | + log.get_log().warning("Connection maybe not release, used time %.2fs %s %s.", now - connection.used_time, connection, self) |
| 310 | + elif self._debug_connection_used: |
| 311 | + log.get_log().warning("Connection used time %.2fs %s %s.\n%s", now - connection.used_time, connection, self, connection.get_last_query_sql()) |
310 | 312 |
|
311 | 313 | next_check_time = now + self._idle_seconds |
312 | 314 | for connection in tuple(self._connections): |
|
0 commit comments