mirror of
				https://github.com/psycopg/psycopg2.git
				synced 2025-10-31 07:47:30 +03:00 
			
		
		
		
	Made the log method a weakreference
This commit is contained in:
		
							parent
							
								
									00870545b7
								
							
						
					
					
						commit
						f511222705
					
				|  | @ -29,8 +29,8 @@ and classes until a better place in the distribution is found. | |||
| import os as _os | ||||
| import time as _time | ||||
| import re as _re | ||||
| import weakref as _weakref | ||||
| from collections import namedtuple, OrderedDict | ||||
| 
 | ||||
| import logging as _logging | ||||
| 
 | ||||
| import psycopg2 | ||||
|  | @ -401,9 +401,15 @@ class LoggingConnection(_connection): | |||
|         self._logobj = logobj | ||||
|         if _logging and isinstance( | ||||
|                 logobj, (_logging.Logger, _logging.LoggerAdapter)): | ||||
|             self.log = self._logtologger | ||||
|             self._log = _weakref.WeakMethod(self._logtologger) | ||||
|         else: | ||||
|             self.log = self._logtofile | ||||
|             self._log = _weakref.WeakMethod(self._logtofile) | ||||
| 
 | ||||
|     def log(self, *args, **kwargs): | ||||
|         """ | ||||
|         Public interface of the log method defined in initialize | ||||
|         """ | ||||
|         return self._log()(*args, **kwargs) | ||||
| 
 | ||||
|     def filter(self, msg, curs): | ||||
|         """Filter the query before logging it. | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user