def _get_handler(settings):
 filename = settings.get('LOG_FILE')
 if filename:
  encoding = settings.get('LOG_ENCODING')
  handler = logging.FileHandler(filename, encoding=encoding)
 elif settings.getbool('LOG_ENABLED'):
  handler = logging.StreamHandler()
 else:
  handler = logging.NullHandler()
 formatter = logging.Formatter(fmt=settings.get('LOG_FORMAT'), datefmt=settings.get('LOG_DATEFORMAT'))
 handler.setFormatter(formatter)
 handler.setLevel(settings.get('LOG_LEVEL'))
 if settings.getbool('LOG_SHORT_NAMES'):
  handler.addFilter(TopLevelFormatter(['scrapy']))
 return handler

def _get_handler ( settings ) : filename = settings . get ( 'LOG_FILE' ) if filename : encoding = settings . get ( 'LOG_ENCODING' ) handler = logging . FileHandler ( filename , encoding = encoding ) elif settings . getbool ( 'LOG_ENABLED' ) : handler = logging . StreamHandler ( ) else : handler = logging . NullHandler ( ) formatter = logging . Formatter ( fmt = settings . get ( 'LOG_FORMAT' ) , datefmt = settings . get ( 'LOG_DATEFORMAT' ) ) handler . setFormatter ( formatter ) handler . setLevel ( settings . get ( 'LOG_LEVEL' ) ) if settings . getbool ( 'LOG_SHORT_NAMES' ) : handler . addFilter ( TopLevelFormatter ( [ 'scrapy' ] ) ) return handler
return a log handler object according to settings .