Example #1
0
 def log(priority_: str,
         type_: str,
         message: str,
         info: Union[str, Exception, None] = None) -> None:
     log_levels = app.config['LOG_LEVELS']
     priority = list(log_levels.keys())[list(log_levels.values()).index(priority_)]
     if int(session['settings']['log_level']) < priority:  # pragma: no cover
         return
     Db.log({
         'priority': priority,
         'type': type_,
         'message': message,
         'user_id': current_user.id if hasattr(current_user, 'id') else None,
         'info': '{method} {path}{info}'.format(
             path=request.path,
             method=request.method,
             info='\n' + str(info) if info else '')})
Example #2
0
 def get_log_for_advanced_view(entity_id: str) -> Dict[str, Any]:
     from openatlas.models.user import User
     data = Db.get_log_for_advanced_view(entity_id)
     return {
         'creator': User.get_by_id(data['creator_id']) if data['creator_id'] else None,
         'created': data['created'],
         'modifier': User.get_by_id(data['modifier_id']) if data['modifier_id'] else None,
         'modified': data['modified'],
         'project': Import.get_project_by_id(data['project_id']) if data['project_id'] else None,
         'importer': User.get_by_id(data['importer_id']) if data['importer_id'] else None,
         'origin_id': data['origin_id']}
Example #3
0
 def log_user(entity_id: int, action: str) -> None:
     Db.log_user(entity_id, current_user.id, action)
Example #4
0
 def delete_all_system_logs() -> None:
     Db.delete_all_system_logs()
Example #5
0
 def get_system_logs(
         limit: str,
         priority: str,
         user_id: str) -> list[dict[str, Any]]:
     return Db.get_system_logs(limit, priority, user_id)