def harvest_log_list(context,data_dict): '''Returns a list of harvester log entries. :param per_page: number of logs to be shown default: 100 :param offset: use with ``per_page`` default: 0 :param level: filter log entries by level(debug, info, warning, error, critical) ''' check_access('harvest_log_list', context, data_dict) model = context['model'] session = context['session'] try: per_page = int(data_dict.get('per_page', 100)) except ValueError: per_page = 100 try: offset = int(data_dict.get('offset', 0)) except ValueError: offset = 0 level = data_dict.get('level', None) query = session.query(HarvestLog) if level is not None: query = query.filter(HarvestLog.level==level.upper()) query = query.order_by(HarvestLog.created.desc()) logs = query.offset(offset).limit(per_page).all() out = [harvest_log_dictize(obj, context) for obj in logs] return out
def harvest_log_list(context, data_dict): '''Returns a list of harvester log entries. :param limit: number of logs to be shown default: 100 :param offset: use with ``per_page`` default: 0 :param level: filter log entries by level(debug, info, warning, error, critical) ''' check_access('harvest_log_list', context, data_dict) model = context['model'] session = context['session'] try: limit = int(data_dict.get('limit', 100)) except ValueError: limit = 100 if data_dict.get('per_page', False): try: limit = int(data_dict.get('per_page', 100)) except ValueError: limit = 100 try: offset = int(data_dict.get('offset', 0)) except ValueError: offset = 0 level = data_dict.get('level', None) query = session.query(HarvestLog) if level is not None: query = query.filter(HarvestLog.level == level.upper()) query = query.order_by(HarvestLog.created.desc()) logs = query.offset(offset).limit(limit).all() out = [harvest_log_dictize(obj, context) for obj in logs] return out