SF.net SVN: fclient: [425] trunk/sandbox/fcp2/consts.py
Status: Pre-Alpha
Brought to you by:
jurner
From: <jU...@us...> - 2008-06-29 15:19:01
|
Revision: 425 http://fclient.svn.sourceforge.net/fclient/?rev=425&view=rev Author: jUrner Date: 2008-06-29 08:19:09 -0700 (Sun, 29 Jun 2008) Log Message: ----------- more fine grained logging support Modified Paths: -------------- trunk/sandbox/fcp2/consts.py Modified: trunk/sandbox/fcp2/consts.py =================================================================== --- trunk/sandbox/fcp2/consts.py 2008-06-29 15:18:28 UTC (rev 424) +++ trunk/sandbox/fcp2/consts.py 2008-06-29 15:19:09 UTC (rev 425) @@ -7,44 +7,29 @@ #***************************************************************************** # exceptions #***************************************************************************** -class MessageParseError(Exception): - """Exception raised when a message could not be parsed succesfuly""" - def __init__(self, message, logMethod=None): +class FcpError(Exception): + def __init__(self, message, logMethod=None, logLevel=None): if logMethod is not None: - logMethod(self.__class__.__name__ + ': %s' % message) + if logLevel is None: + logMethod(self.__class__.__name__ + ': %s' % message) + else: + logMethod(logLevel, self.__class__.__name__ + ': %s' % message) Exception.__init__(self, message) - -class IOConnectFailedError(Exception): +class MessageParseError(FcpError): + """Exception raised when a message could not be parsed succesfuly""" + +class IOConnectFailedError(FcpError): """Exception raised if the object can not be connected""" - def __init__(self, message, logMethod=None): - if logMethod is not None: - logMethod(self.__class__.__name__ + ': %s' % message) - Exception.__init__(self, message) - -class IOClosedError(Exception): +class IOClosedError(FcpError): """Exception raised if the object is closed""" - def __init__(self, message, logMethod=None): - if logMethod is not None: - logMethod(self.__class__.__name__ + ': %s' % message) - Exception.__init__(self, message) - -class IOBrokenError(Exception): +class IOBrokenError(FcpError): """Exception raised if the IO connection is broken""" - def __init__(self, message, logMethod=None): - if logMethod is not None: - logMethod(self.__class__.__name__ + ': %s' % message) - Exception.__init__(self, message) - class IOTimeoutError(Exception): """Exception raised when the io connection is closed""" - def __init__(self, message, logMethod=None): - if logMethod is not None: - logMethod(self.__class__.__name__ + ': %s' % message) - Exception.__init__(self, message) #************************************************************************ # @@ -155,6 +140,7 @@ class DebugVerbosity: """Consts indicating the verbosity level for debugging""" + Chatty = logging.DEBUG - 1 Debug = logging.DEBUG Info = logging.INFO Warning = logging.WARNING @@ -291,11 +277,12 @@ IOHandler =logging.getLogger('Fcp.Client.IOHandler') IO =logging.getLogger('Fcp.Client.IOHandler.IO') Message = logging.getLogger('Fcp.Client.Message') - +logging.addLevelName(DebugVerbosity.Chatty, 'chatty') +logging.addLevelName(DebugVerbosity.Quiet, 'quiet') logging.basicConfig(stream=sys.stdout, level=logging.DEBUG) -logging.addLevelName(DebugVerbosity.Quiet, '') + class LogMessages: """Strings used for log infos""" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |