diff --git a/src/operations/command.ts b/src/operations/command.ts index 1cf4ad90bd1..9945ba0aa6b 100644 --- a/src/operations/command.ts +++ b/src/operations/command.ts @@ -160,10 +160,6 @@ export abstract class CommandOperation extends AbstractOperation { cmd.comment = options.comment; } - if (this.logger && this.logger.isDebug()) { - this.logger.debug(`executing command ${JSON.stringify(cmd)} against ${this.ns}`); - } - if (this.hasAspect(Aspect.EXPLAINABLE) && this.explain) { if (serverWireVersion < 6 && cmd.aggregate) { // Prior to 3.6, with aggregate, verbosity is ignored, and we must pass in "explain: true" diff --git a/src/sdam/server.ts b/src/sdam/server.ts index 18c7b2cc9d7..76acdcd4613 100644 --- a/src/sdam/server.ts +++ b/src/sdam/server.ts @@ -10,7 +10,6 @@ import { Monitor, MonitorOptions } from './monitor'; import { isTransactionCommand } from '../transactions'; import { collationNotSupported, - debugOptions, makeStateMachine, maxWireVersion, Callback, @@ -56,34 +55,6 @@ import type { AutoEncrypter } from '../deps'; import type { ServerApi } from '../mongo_client'; import { TypedEventEmitter } from '../mongo_types'; -// Used for filtering out fields for logging -const DEBUG_FIELDS = [ - 'reconnect', - 'reconnectTries', - 'reconnectInterval', - 'emitError', - 'cursorFactory', - 'host', - 'port', - 'size', - 'keepAlive', - 'keepAliveInitialDelay', - 'noDelay', - 'connectionTimeout', - 'checkServerIdentity', - 'socketTimeoutMS', - 'ssl', - 'ca', - 'crl', - 'cert', - 'key', - 'rejectUnauthorized', - 'promoteLongs', - 'promoteValues', - 'promoteBuffers', - 'servername' -]; - const stateTransition = makeStateMachine({ [STATE_CLOSED]: [STATE_CLOSED, STATE_CONNECTING], [STATE_CONNECTING]: [STATE_CONNECTING, STATE_CLOSING, STATE_CONNECTED, STATE_CLOSED], @@ -304,17 +275,6 @@ export class Server extends TypedEventEmitter { // Clone the options const finalOptions = Object.assign({}, options, { wireProtocolCommand: false }); - // Debug log - if (this.s.logger.isDebug()) { - this.s.logger.debug( - `executing command [${JSON.stringify({ - ns, - cmd, - options: debugOptions(DEBUG_FIELDS, options) - })}] against ${this.name}` - ); - } - // error if collation not supported if (collationNotSupported(this, cmd)) { callback(new MongoDriverError(`server ${this.name} does not support collation`)); diff --git a/src/utils.ts b/src/utils.ts index afee8d7ed65..80bc3a09cef 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -172,17 +172,6 @@ export function isObject(arg: unknown): arg is object { return '[object Object]' === Object.prototype.toString.call(arg); } -/** @internal */ -export function debugOptions(debugFields: string[], options?: AnyOptions): Document { - const finalOptions: AnyOptions = {}; - if (!options) return finalOptions; - debugFields.forEach(n => { - finalOptions[n] = options[n]; - }); - - return finalOptions; -} - /** @internal */ export function decorateCommand(command: Document, options: Document, exclude: string[]): Document { for (const name in options) { diff --git a/test/functional/logger.test.js b/test/functional/logger.test.js deleted file mode 100644 index d92a1eaab7b..00000000000 --- a/test/functional/logger.test.js +++ /dev/null @@ -1,145 +0,0 @@ -'use strict'; -const expect = require('chai').expect; -const { withClient } = require('./shared'); -const { Logger } = require('../../src/logger'); - -describe('Logger', function () { - /** - * Test a simple find - */ - it('should correctly Enable logging', { - metadata: { requires: { topology: ['single'] } }, - - test: function (done) { - var self = this; - var client = self.configuration.newClient(self.configuration.writeConcernMax(), { - maxPoolSize: 1 - }); - - client.connect(function (err, client) { - var db = client.db(self.configuration.db); - expect(err).to.not.exist; - - // Logging setup - Logger.setLevel('debug'); - Logger.filter('class', ['Db']); - - // Status - var logged = false; - - // Logger. - Logger.setCurrentLogger(function (msg, context) { - expect(msg).to.exist; - expect(context.type).to.equal('debug'); - expect(context.className).to.equal('Db'); - logged = true; - }); - - // Execute the command - db.command({ ismaster: true }, function (err) { - expect(err).to.not.exist; - expect(logged).to.be.true; - - // Clean up - Logger.reset(); - client.close(done); - }); - }); - } - }); - - /** - * Should No fail with undefined id - */ - it('should not fail with undefined id', { - metadata: { requires: { topology: ['single'] } }, - - test: function () { - // set a custom logger per http://mongodb.github.io/node-mongodb-native/2.0/tutorials/logging/ - Logger.setCurrentLogger(function () {}); - Logger.setLevel('debug'); - - return withClient('mongodb://localhost:27017/test', (client, done) => { - const db = client.db(this.configuration.db); - // perform any operation that gets logged - db.collection('foo').findOne({}, function (err) { - expect(err).to.not.exist; - - // Clean up - Logger.reset(); - done(); - }); - }); - } - }); - - /** - * Should No fail with undefined id - */ - it('should correctly log cursor', { - metadata: { requires: { topology: ['single'] } }, - - test: function () { - return withClient('mongodb://localhost:27017/test', (client, done) => { - const db = client.db(this.configuration.db); - // Status - var logged = false; - - // Set the current logger - Logger.setCurrentLogger(function (msg, context) { - expect(msg).to.exist; - expect(context.type).to.equal('debug'); - expect(context.className).to.equal('Cursor'); - logged = true; - }); - - // Set the filter - Logger.setLevel('debug'); - Logger.filter('class', ['Cursor']); - - // perform any operation that gets logged - db.collection('logging') - .find() - .toArray(function (err) { - expect(err).to.not.exist; - expect(logged).to.be.true; - - // Clean up - Logger.reset(); - done(); - }); - }); - } - }); - - /** - * Should No fail with undefined id - */ - it('should pass the logLevel down through the options', { - metadata: { requires: { topology: ['single'] } }, - - test: function () { - Logger.filter('class', ['Cursor']); - var logged = false; - - return withClient('mongodb://localhost:27017/test', (client, done) => { - const db = client.db(this.configuration.db, { - loggerLevel: 'debug', - logger: function () { - logged = true; - } - }); - - // perform any operation that gets logged - db.collection('foo').findOne({}, function (err) { - expect(err).to.not.exist; - expect(logged).to.be.true; - - // Clean up - Logger.reset(); - done(); - }); - }); - } - }); -});