def log_user_ip(uid): user_id = str(request.remote_addr) question_id = "corgis" event = "corgis" action = "record" body = str(uid) external_interactions_logger = logging.getLogger('ExternalInteractions') external_interactions_logger.info( StructuredEvent(user_id, question_id, event, action, body))
def new(event, action, assignment_id, user_id): # Database logging log = Log(event=event, action=action, assignment_id=assignment_id, user_id=user_id) db.session.add(log) db.session.commit() # Single-file logging student_interactions_logger = logging.getLogger('StudentInteractions') student_interactions_logger.info( StructuredEvent(user_id, assignment_id, event, action, '')) return log
def log_event(): if 'user_id' in request.values: user_id = request.values.get('user_id') elif 'user' in g and g.user and g.user.id: user_id = g.user.id else: user_id = str(request.remote_addr) assignment_id = request.values.get('assignment_id', "") event = request.values.get('event', "") action = request.values.get('action', "") body = request.values.get('body', "") external_interactions_logger = logging.getLogger('StudentInteractions') external_interactions_logger.info( StructuredEvent(user_id, assignment_id, event, action, body)) return jsonify(success=True)
def log_event(): user_id = request.form.get('user_id', "") if user_id == "": user_id = str(request.remote_addr) question_id = request.form.get('question_id', "") event = request.form.get('event', "") action = request.form.get('action', "") body = request.form.get('body', "") external_interactions_logger = logging.getLogger('ExternalInteractions') external_interactions_logger.info( StructuredEvent(user_id, question_id, event, action, body) ) response = make_response('success') response.headers['Access-Control-Allow-Origin'] = "*" return response
def log_code(self, extension='.py'): ''' Store the code on disk, mapped to the Assignment ID and the Student ID ''' # Multiple-file logging directory = os.path.join(app.config['BLOCKLY_LOG_DIR'], str(self.assignment_id), str(self.user_id)) ensure_dirs(directory) name = time.strftime("%Y%m%d-%H%M%S") file_name = os.path.join(directory, name + extension) with open(file_name, 'wb') as blockly_logfile: blockly_logfile.write(self.code) # Single file logging student_interactions_logger = logging.getLogger('StudentInteractions') student_interactions_logger.info( StructuredEvent(self.user_id, self.assignment_id, 'code', 'set', self.code))