Skip to content

Commit

Permalink
separate logger for components
Browse files Browse the repository at this point in the history
  • Loading branch information
sibiryakov committed Jul 22, 2016
1 parent 81c3258 commit fabe19d
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions frontera/core/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,19 @@

class ComponentsPipelineMixin(object):
def __init__(self, backend, middlewares=None, canonicalsolver=None, db_worker=False, strategy_worker=False):
self._logger_components = logging.getLogger("manager.components")

# Load middlewares
self._middlewares = self._load_middlewares(middlewares)

# Load canonical solver
self._logger.debug("Loading canonical url solver '%s'", canonicalsolver)
self._logger_components.debug("Loading canonical url solver '%s'", canonicalsolver)
self._canonicalsolver = self._load_object(canonicalsolver)
assert isinstance(self.canonicalsolver, CanonicalSolver), \
"canonical solver '%s' must subclass CanonicalSolver" % self.canonicalsolver.__class__.__name__

# Load backend
self._logger.debug("Loading backend '%s'", backend)
self._logger_components.debug("Loading backend '%s'", backend)
self._backend = self._load_backend(backend, db_worker, strategy_worker)

@property
Expand Down Expand Up @@ -67,14 +69,14 @@ def _load_middlewares(self, middleware_names):
# TO-DO: Use dict for middleware ordering
mws = []
for mw_name in middleware_names or []:
self._logger.debug("Loading middleware '%s'", mw_name)
self._logger_components.debug("Loading middleware '%s'", mw_name)
try:
mw = self._load_object(mw_name, silent=False)
assert isinstance(mw, Middleware), "middleware '%s' must subclass Middleware" % mw.__class__.__name__
if mw:
mws.append(mw)
except NotConfigured:
self._logger.warning("middleware '%s' disabled!", mw_name)
self._logger_components.warning("middleware '%s' disabled!", mw_name)

return mws

Expand All @@ -89,14 +91,14 @@ def _process_components(self, method_name, obj=None, return_classes=None, **kwar
if check_response:
return_obj = result
if check_response and obj and not return_obj:
self._logger.warning("Object '%s' filtered in '%s' by '%s'",
self._logger_components.warning("Object '%s' filtered in '%s' by '%s'",
obj.__class__.__name__, method_name, component.__class__.__name__
)
return
return return_obj

def _process_component(self, component, method_name, component_category, obj, return_classes, **kwargs):
self._logger.debug("processing '%s' '%s.%s' %s",
self._logger_components.debug("processing '%s' '%s.%s' %s",
method_name, component_category, component.__class__.__name__, obj)
return_obj = getattr(component, method_name)(*([obj] if obj else []), **kwargs)
assert return_obj is None or isinstance(return_obj, return_classes), \
Expand Down

0 comments on commit fabe19d

Please sign in to comment.