def get_handler(debug=False, syslog=False, logfile=None, rotation_parameters=None):
 if os.environ.get('APYCOT_ROOT'):
  handler = logging.StreamHandler(sys.stdout)
 if debug:
  handler = logging.StreamHandler()
 elif (logfile is None):
  if syslog:
   from logging import handlers
   handler = handlers.SysLogHandler()
  else:
   handler = logging.StreamHandler()
 else:
  try:
   if (rotation_parameters is None):
    if ((os.name == 'posix') and (sys.version_info >= (2, 6))):
     from logging.handlers import WatchedFileHandler
     handler = WatchedFileHandler(logfile)
    else:
     handler = logging.FileHandler(logfile)
   else:
    from logging.handlers import TimedRotatingFileHandler
    handler = TimedRotatingFileHandler(logfile, **rotation_parameters)
  except IOError:
   handler = logging.StreamHandler()
 return handler

def get_handler ( debug = False , syslog = False , logfile = None , rotation_parameters = None ) : if os . environ . get ( 'APYCOT_ROOT' ) : handler = logging . StreamHandler ( sys . stdout ) if debug : handler = logging . StreamHandler ( ) elif ( logfile is None ) : if syslog : from logging import handlers handler = handlers . SysLogHandler ( ) else : handler = logging . StreamHandler ( ) else : try : if ( rotation_parameters is None ) : if ( ( os . name == 'posix' ) and ( sys . version_info >= ( 2 , 6 ) ) ) : from logging . handlers import WatchedFileHandler handler = WatchedFileHandler ( logfile ) else : handler = logging . FileHandler ( logfile ) else : from logging . handlers import TimedRotatingFileHandler handler = TimedRotatingFileHandler ( logfile , ** rotation_parameters ) except IOError : handler = logging . StreamHandler ( ) return handler
get an apropriate handler according to given parameters .