lib/operations/db_ops.js
function setProfilingLevel(db, level, options, callback) {
  const command = {};
  let profile = 0;

  if (level === 'off') {
    profile = 0;
  } else if (level === 'slow_only') {
    profile = 1;
  } else if (level === 'all') {
    profile = 2;
  } else {
    return callback(new Error('Error: illegal profiling level value ' + level));
  }

  // Set up the profile number
  command['profile'] = profile;

  executeCommand(db, command, options, (err, doc) => {
    if (err == null && doc.ok === 1) return callback(null, level);
    return err != null
      ? callback(err, null)
      : callback(new Error('Error with profile command'), null);
  });
}
function setProfilingLevel(db, level, options, callback) {
  const command = {};
  let profile = 0;

  if (level === 'off') {
    profile = 0;
  } else if (level === 'slow_only') {
    profile = 1;
  } else if (level === 'all') {
    profile = 2;
  } else {
    return callback(new Error('Error: illegal profiling level value ' + level));
  }

  // Set up the profile number
  command['profile'] = profile;

  executeCommand(db, command, options, (err, doc) => {
    if (err == null && doc.ok === 1) return callback(null, level);
    return err != null
      ? callback(err, null)
      : callback(new Error('Error with profile command'), null);
  });
}
function setProfilingLevel ( db , level , options , callback ) { const command = { } ; let profile = 0 ; if ( level === 'off' ) { profile = 0 ; } else if ( level === 'slow_only' ) { profile = 1 ; } else if ( level === 'all' ) { profile = 2 ; } else { return callback ( new Error ( 'Error: illegal profiling level value ' + level ) ) ; } // Set up the profile number command [ 'profile' ] = profile ; executeCommand ( db , command , options , ( err , doc ) => { if ( err == null && doc . ok === 1 ) return callback ( null , level ) ; return err != null ? callback ( err , null ) : callback ( new Error ( 'Error with profile command' ) , null ) ; } ) ; }
Set the current profiling level of MongoDB

@method
@param {Db} db The Db instance on which to execute the command.
@param {string} level The new profiling level (off, slow_only, all).
@param {Object} [options] Optional settings. See Db.prototype.setProfilingLevel for a list of options.
@param {Db~resultCallback} [callback] The command result callback.
Set the current profiling level of MongoDB