code: def set_profiling_level(self, level, slow_ms=None, session=None):
          
          if not isinstance(level, int) or level < 0 or level > 2:
              raise ValueError("level must be one of (OFF, SLOW_ONLY, ALL)")
  
          if slow_ms is not None and not isinstance(slow_ms, int):
              raise TypeError("slow_ms must be an integer")
  
          if slow_ms is not None:
              self.command("profile", level, slowms=slow_ms, session=session)
          else:
              self.command("profile", level, session=session)
docs: Set the database's profiling level.
  
          :Parameters:
            - `level`: Specifies a profiling level, see list of possible values
              below.
            - `slow_ms`: Optionally modify the threshold for the profile to
              consider a query or operation.  Even if the profiler is off queries
              slower than the `slow_ms` level will get written to the logs.
            - `session` (optional): a
              :class:`~pymongo.client_session.ClientSession`.
  
          Possible `level` values:
  
          +----------------------------+------------------------------------+
          | Level                      | Setting                            |
          +============================+====================================+
          | :data:`~pymongo.OFF`       | Off. No profiling.                 |
          +----------------------------+------------------------------------+
          | :data:`~pymongo.SLOW_ONLY` | On. Only includes slow operations. |
          +----------------------------+------------------------------------+
          | :data:`~pymongo.ALL`       | On. Includes all operations.       |
          +----------------------------+------------------------------------+
  
          Raises :class:`ValueError` if level is not one of
          (:data:`~pymongo.OFF`, :data:`~pymongo.SLOW_ONLY`,
          :data:`~pymongo.ALL`).
  
          .. versionchanged:: 3.6
             Added ``session`` parameter.
  
          .. mongodoc:: profiling