pgtoolkit/pgmanager.py
changeset 20 73f0d53fef6b
parent 19 e526ca146fa9
child 23 dc2dbe872fc8
--- a/pgtoolkit/pgmanager.py	Sun Nov 27 17:02:42 2011 +0100
+++ b/pgtoolkit/pgmanager.py	Tue Dec 06 16:20:53 2011 +0100
@@ -81,6 +81,9 @@
 from psycopg2 import DatabaseError, IntegrityError, OperationalError
 
 
+log = logging.getLogger("pgmanager")
+
+
 class PgManagerError(Exception):
 
     pass
@@ -351,26 +354,13 @@
             raise PgManagerError('Unknown isolation level name: "%s"', level)
         return level
 
-
-try:
-    NullHandler = logging.NullHandler
-except AttributeError:
-    class NullHandler(logging.Handler):
-        def emit(self, record):
-            pass
-
-
-log = logging.getLogger("pgmanager")
-log.addHandler(NullHandler())
-
-
-instance = None
+    @classmethod
+    def get_instance(cls):
+        if not hasattr(cls, '_instance'):
+            cls._instance = cls()
+        return cls._instance
 
 
 def get_instance():
-    global instance
-    if instance is None:
-        instance = PgManager()
-    return instance
+    return PgManager.get_instance()
 
-