profiling_level.js 1.3 KB

123456789101112131415161718192021222324252627282930313233
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.ProfilingLevelOperation = void 0;
  4. const error_1 = require("../error");
  5. const command_1 = require("./command");
  6. /** @internal */
  7. class ProfilingLevelOperation extends command_1.CommandOperation {
  8. constructor(db, options) {
  9. super(db, options);
  10. this.options = options;
  11. }
  12. execute(server, session, callback) {
  13. super.executeCommand(server, session, { profile: -1 }, (err, doc) => {
  14. if (err == null && doc.ok === 1) {
  15. const was = doc.was;
  16. if (was === 0)
  17. return callback(undefined, 'off');
  18. if (was === 1)
  19. return callback(undefined, 'slow_only');
  20. if (was === 2)
  21. return callback(undefined, 'all');
  22. // TODO(NODE-3483)
  23. return callback(new error_1.MongoRuntimeError(`Illegal profiling level value ${was}`));
  24. }
  25. else {
  26. // TODO(NODE-3483): Consider MongoUnexpectedServerResponseError
  27. err != null ? callback(err) : callback(new error_1.MongoRuntimeError('Error with profile command'));
  28. }
  29. });
  30. }
  31. }
  32. exports.ProfilingLevelOperation = ProfilingLevelOperation;
  33. //# sourceMappingURL=profiling_level.js.map