cc-4105: removed unused code. refactored logging a bit
This commit is contained in:
parent
b22b9b9aa3
commit
a2333309a7
|
@ -57,15 +57,12 @@ class BaseEvent(Loggable):
|
||||||
self.path = os.path.normpath(raw_event.pathname)
|
self.path = os.path.normpath(raw_event.pathname)
|
||||||
else: self.path = raw_event
|
else: self.path = raw_event
|
||||||
self._pack_hook = lambda: None # no op
|
self._pack_hook = lambda: None # no op
|
||||||
self._morph_target = False # returns true if event was used to moprh
|
|
||||||
# into another event
|
# into another event
|
||||||
def exists(self): return os.path.exists(self.path)
|
def exists(self): return os.path.exists(self.path)
|
||||||
@LazyProperty
|
@LazyProperty
|
||||||
def cookie(self):
|
def cookie(self):
|
||||||
return getattr( self._raw_event, 'cookie', None )
|
return getattr( self._raw_event, 'cookie', None )
|
||||||
|
|
||||||
def morph_target(self): return self._morph_target
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "Event(%s). Path(%s)" % ( self.path, self.__class__.__name__)
|
return "Event(%s). Path(%s)" % ( self.path, self.__class__.__name__)
|
||||||
def is_dir_event(self): return self._raw_event.dir
|
def is_dir_event(self): return self._raw_event.dir
|
||||||
|
@ -98,7 +95,6 @@ class BaseEvent(Loggable):
|
||||||
self._raw_event = evt
|
self._raw_event = evt
|
||||||
self.path = evt.path
|
self.path = evt.path
|
||||||
self.__class__ = evt.__class__
|
self.__class__ = evt.__class__
|
||||||
evt._morph_target = True
|
|
||||||
self.add_safe_pack_hook(evt._pack_hook)
|
self.add_safe_pack_hook(evt._pack_hook)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
|
|
@ -3,16 +3,22 @@ import abc
|
||||||
import traceback
|
import traceback
|
||||||
from media.monitor.pure import LazyProperty
|
from media.monitor.pure import LazyProperty
|
||||||
|
|
||||||
|
appname = 'root'
|
||||||
|
|
||||||
def setup_logging(log_path):
|
def setup_logging(log_path):
|
||||||
#logger = logging.getLogger('mediamonitor2')
|
#logger = logging.getLogger(appname)
|
||||||
logging.basicConfig(filename=log_path, level=logging.DEBUG)
|
logging.basicConfig(filename=log_path, level=logging.DEBUG)
|
||||||
|
|
||||||
appname = 'mediamonitor2'
|
def get_logger():
|
||||||
|
"""
|
||||||
|
in case we want to use the common logger from a procedural interface
|
||||||
|
"""
|
||||||
|
return logging.getLogger()
|
||||||
|
|
||||||
class Loggable(object):
|
class Loggable(object):
|
||||||
__metaclass__ = abc.ABCMeta
|
__metaclass__ = abc.ABCMeta
|
||||||
@LazyProperty
|
@LazyProperty
|
||||||
def logger(self): return logging.getLogger(appname)
|
def logger(self): return get_logger()
|
||||||
|
|
||||||
def unexpected_exception(self,e):
|
def unexpected_exception(self,e):
|
||||||
"""
|
"""
|
||||||
|
@ -28,8 +34,3 @@ class Loggable(object):
|
||||||
self.logger.error( str(e) )
|
self.logger.error( str(e) )
|
||||||
self.logger.error( traceback.format_exc() )
|
self.logger.error( traceback.format_exc() )
|
||||||
|
|
||||||
def get_logger():
|
|
||||||
"""
|
|
||||||
in case we want to use the common logger from a procedural interface
|
|
||||||
"""
|
|
||||||
return logging.getLogger(appname)
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ def main(global_config, api_client_config, log_config,
|
||||||
print(str(e))
|
print(str(e))
|
||||||
|
|
||||||
|
|
||||||
#logging.config.fileConfig(log_config)
|
logging.config.fileConfig(log_config)
|
||||||
|
|
||||||
#need to wait for Python 2.7 for this..
|
#need to wait for Python 2.7 for this..
|
||||||
#logging.captureWarnings(True)
|
#logging.captureWarnings(True)
|
||||||
|
|
Loading…
Reference in New Issue