stop redundant logging
authorTony Mack <tmack@paris.CS.Princeton.EDU>
Mon, 20 Jun 2011 17:04:31 +0000 (13:04 -0400)
committerTony Mack <tmack@paris.CS.Princeton.EDU>
Mon, 20 Jun 2011 17:04:31 +0000 (13:04 -0400)
sfa/client/sfadump.py
sfa/client/sfascan.py
sfa/rspecs/pg_rspec.py
sfa/util/sfalogging.py

index b1169b9..1ea1a7c 100755 (executable)
@@ -13,7 +13,7 @@ from sfa.trust.credential import Credential
 from sfa.trust.gid import GID
 from sfa.util.record import SfaRecord
 from sfa.util.rspec import RSpec
-from sfa.util.sfalogging import sfa_logger, sfa_logger_goes_to_console
+from sfa.util.sfalogging import sfa_logger
 
 def determine_sfa_filekind(fn):
 
@@ -100,7 +100,6 @@ def handle_input_kind (filename, options, kind):
         print "%s: unknown filekind '%s'"% (filename,kind)
 
 def main():
-    sfa_logger_goes_to_console()
     usage = """%prog file1 [ .. filen]
 display info on input files"""
     parser = OptionParser(usage=usage)
index f85384d..eff17ec 100755 (executable)
@@ -10,7 +10,7 @@ import pygraphviz
 from optparse import OptionParser
 
 from sfa.client.sfi import Sfi
-from sfa.util.sfalogging import sfa_logger,sfa_logger_goes_to_console
+from sfa.util.sfalogging import sfa_logger
 import sfa.util.xmlrpcprotocol as xmlrpcprotocol
 
 def url_hostname_port (url):
@@ -201,7 +201,6 @@ class SfaScan:
 default_outfiles=['sfa.png','sfa.svg','sfa.dot']
 
 def main():
-    sfa_logger_goes_to_console()
     usage="%prog [options] url-entry-point(s)"
     parser=OptionParser(usage=usage)
     parser.add_option("-o","--output",action='append',dest='outfiles',default=[],
index 3d2ae4f..7c3f760 100755 (executable)
@@ -32,7 +32,7 @@ pg_rspec_request_version = RSpecVersion(_request_version)
 class PGRSpec(RSpec):
     xml = None
     header = '<?xml version="1.0"?>\n'
-    template = """<rspec xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.protogeni.net/resources/rspec/2" xsi:schemaLocation="http://www.protogeni.net/resources/rspec/2 http://www.protogeni.net/resources/rspec/2/%(rspec_type)s.xsd"></rspec>"""
+    template = '<rspec xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.protogeni.net/resources/rspec/2" xsi:schemaLocation="http://www.protogeni.net/resources/rspec/2 http://www.protogeni.net/resources/rspec/2/%(rspec_type)s.xsd"/>'
 
     def __init__(self, rspec="", namespaces={}, type=None):
         if not type:
index 42e2e67..b4a1290 100755 (executable)
@@ -54,24 +54,21 @@ class _SfaLogger:
             self.logger.setLevel(logging.DEBUG)
 
     ####################
-    def wrap(fun):
-        def wrapped(self,msg,*args,**kwds):
-            native=getattr(self.logger,fun.__name__)
-            return native(msg,*args,**kwds)
-        #wrapped.__doc__=native.__doc__
-        return wrapped
-
-    @wrap
-    def critical(): pass
-    @wrap
-    def error(): pass
-    @wrap
-    def warning(): pass
-    @wrap
-    def info(): pass
-    @wrap
-    def debug(): pass
-    
+    def info(self, msg):
+        self.logger.info(msg)
+
+    def debug(self, msg):
+        self.logger.debug(msg)
+        
+    def warn(self, msg):
+        self.logger.warn(msg)
+   
+    def error(self, msg):
+        self.logger.error(msg)    
+    def critical(self, msg):
+        self.logger.critical(msg)
+
     # logs an exception - use in an except statement
     def log_exc(self,message):
         self.error("%s BEG TRACEBACK"%message+"\n"+traceback.format_exc().strip("\n"))
@@ -92,25 +89,25 @@ class _SfaLogger:
 _import_logger=_SfaLogger(logfile='/var/log/sfa_import.log')
 # servers log into /var/log/sfa.log
 _server_logger=_SfaLogger(logfile='/var/log/sfa.log')
-# clients use the console
-_console_logger=_SfaLogger()
+## clients use the console
+#_console_logger=_SfaLogger()
 
 # default is to use the server-side logger
-_the_logger=_server_logger
+#_the_logger=_server_logger
 
 # clients would change the default by issuing one of these call
-def sfa_logger_goes_to_console():
-    current_module=sys.modules[globals()['__name__']]
-    current_module._the_logger=_console_logger
-
+#def sfa_logger_goes_to_console():
+#    current_module=sys.modules[globals()['__name__']]
+#    current_module._the_logger=_console_logger
+#
 # clients would change the default by issuing one of these call
-def sfa_logger_goes_to_import():
-    current_module=sys.modules[globals()['__name__']]
-    current_module._the_logger=_import_logger
+#def sfa_logger_goes_to_import():
+#    current_module=sys.modules[globals()['__name__']]
+#    current_module._the_logger=_import_logger
 
 # this is how to retrieve the 'right' logger
 def sfa_logger():
-    return _the_logger
+    return _server_logger
 
 ########################################
 import time
@@ -148,7 +145,7 @@ if __name__ == '__main__':
     logger.setLevel(logging.DEBUG)
     logger.debug("logger.debug again")
     
-    sfa_logger_goes_to_console()
+    #sfa_logger_goes_to_console()
     my_logger=sfa_logger()
     my_logger.info("redirected to console")