@get('/scan/<taskid>/log/<start>/<end>')
def scan_log_limited(taskid, start, end):
 json_log_messages = list()
 if (taskid not in DataStore.tasks):
  logger.warning(('[%s] Invalid task ID provided to scan_log_limited()' % taskid))
  return jsonize({'success': False, 'message': 'Invalid task ID'})
 if ((not start.isdigit()) or (not end.isdigit()) or (end < start)):
  logger.warning(('[%s] Invalid start or end value provided to scan_log_limited()' % taskid))
  return jsonize({'success': False, 'message': 'Invalid start or end value, must be digits'})
 start = max(1, int(start))
 end = max(1, int(end))
 for (time_, level, message) in DataStore.current_db.execute('SELECT time, level, message FROM logs WHERE taskid = ? AND id >= ? AND id <= ? ORDER BY id ASC', (taskid, start, end)):
  json_log_messages.append({'time': time_, 'level': level, 'message': message})
 logger.debug(('[%s] Retrieved scan log messages subset' % taskid))
 return jsonize({'success': True, 'log': json_log_messages})

@ get ( '/scan/<taskid>/log/<start>/<end>' ) def scan_log_limited ( taskid , start , end ) : json_log_messages = list ( ) if ( taskid not in DataStore . tasks ) : logger . warning ( ( '[%s] Invalid task ID provided to scan_log_limited()' % taskid ) ) return jsonize ( { 'success' : False , 'message' : 'Invalid task ID' } ) if ( ( not start . isdigit ( ) ) or ( not end . isdigit ( ) ) or ( end < start ) ) : logger . warning ( ( '[%s] Invalid start or end value provided to scan_log_limited()' % taskid ) ) return jsonize ( { 'success' : False , 'message' : 'Invalid start or end value, must be digits' } ) start = max ( 1 , int ( start ) ) end = max ( 1 , int ( end ) ) for ( time_ , level , message ) in DataStore . current_db . execute ( 'SELECT time, level, message FROM logs WHERE taskid = ? AND id >= ? AND id <= ? ORDER BY id ASC' , ( taskid , start , end ) ) : json_log_messages . append ( { 'time' : time_ , 'level' : level , 'message' : message } ) logger . debug ( ( '[%s] Retrieved scan log messages subset' % taskid ) ) return jsonize ( { 'success' : True , 'log' : json_log_messages } )
retrieve a subset of log messages .