Skip to content

Commit 28c7cdd

Browse files
authored
feat(NODE-4817)!: remove legacy logger (#3518)
1 parent b850868 commit 28c7cdd

21 files changed

+13
-810
lines changed

src/cmap/connection_pool.ts

-6
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import {
2222
MongoRuntimeError,
2323
MongoServerError
2424
} from '../error';
25-
import { Logger } from '../logger';
2625
import { CancellationToken, TypedEventEmitter } from '../mongo_types';
2726
import type { Server } from '../sdam/server';
2827
import { Callback, eachAsync, List, makeCounter } from '../utils';
@@ -52,8 +51,6 @@ import { ConnectionPoolMetrics } from './metrics';
5251
/** @internal */
5352
const kServer = Symbol('server');
5453
/** @internal */
55-
const kLogger = Symbol('logger');
56-
/** @internal */
5754
const kConnections = Symbol('connections');
5855
/** @internal */
5956
const kPending = Symbol('pending');
@@ -140,7 +137,6 @@ export class ConnectionPool extends TypedEventEmitter<ConnectionPoolEvents> {
140137
options: Readonly<ConnectionPoolOptions>;
141138
[kPoolState]: typeof PoolState[keyof typeof PoolState];
142139
[kServer]: Server;
143-
[kLogger]: Logger;
144140
[kConnections]: List<Connection>;
145141
[kPending]: number;
146142
[kCheckedOut]: Set<Connection>;
@@ -239,7 +235,6 @@ export class ConnectionPool extends TypedEventEmitter<ConnectionPoolEvents> {
239235

240236
this[kPoolState] = PoolState.paused;
241237
this[kServer] = server;
242-
this[kLogger] = new Logger('ConnectionPool');
243238
this[kConnections] = new List();
244239
this[kPending] = 0;
245240
this[kCheckedOut] = new Set();
@@ -642,7 +637,6 @@ export class ConnectionPool extends TypedEventEmitter<ConnectionPoolEvents> {
642637

643638
connect(connectOptions, (err, connection) => {
644639
if (err || !connection) {
645-
this[kLogger].debug(`connection attempt failed with error [${JSON.stringify(err)}]`);
646640
this[kPending]--;
647641
this.emit(
648642
ConnectionPool.CONNECTION_CLOSED,

src/collection.ts

+1-14
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { FindCursor } from './cursor/find_cursor';
88
import { ListIndexesCursor } from './cursor/list_indexes_cursor';
99
import type { Db } from './db';
1010
import { MongoInvalidArgumentError } from './error';
11-
import type { Logger, LoggerOptions } from './logger';
1211
import type { PkFactory } from './mongo_client';
1312
import type {
1413
Filter,
@@ -105,10 +104,7 @@ export interface ModifyResult<TSchema = Document> {
105104
}
106105

107106
/** @public */
108-
export interface CollectionOptions
109-
extends BSONSerializeOptions,
110-
WriteConcernOptions,
111-
LoggerOptions {
107+
export interface CollectionOptions extends BSONSerializeOptions, WriteConcernOptions {
112108
/** Specify a read concern for the collection. (only MongoDB 3.2 or higher supported) */
113109
readConcern?: ReadConcernLike;
114110
/** The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). */
@@ -1535,15 +1531,6 @@ export class Collection<TSchema extends Document = Document> {
15351531
return new OrderedBulkOperation(this as TODO_NODE_3286, resolveOptions(this, options));
15361532
}
15371533

1538-
/** Get the db scoped logger */
1539-
getLogger(): Logger {
1540-
return this.s.db.s.logger;
1541-
}
1542-
1543-
get logger(): Logger {
1544-
return this.s.db.s.logger;
1545-
}
1546-
15471534
/**
15481535
* An estimated count of matching documents in the db to a filter.
15491536
*

src/connection_string.ts

-19
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import {
1414
MongoMissingCredentialsError,
1515
MongoParseError
1616
} from './error';
17-
import { Logger as LegacyLogger, LoggerLevel as LegacyLoggerLevel } from './logger';
1817
import {
1918
DriverInfo,
2019
MongoClient,
@@ -870,24 +869,6 @@ export const OPTIONS = {
870869
default: 15,
871870
type: 'uint'
872871
},
873-
logger: {
874-
default: new LegacyLogger('MongoClient'),
875-
transform({ values: [value] }) {
876-
if (value instanceof LegacyLogger) {
877-
return value;
878-
}
879-
emitWarning('Alternative loggers might not be supported');
880-
// TODO: make Logger an interface that others can implement, make usage consistent in driver
881-
// DRIVERS-1204
882-
return;
883-
}
884-
},
885-
loggerLevel: {
886-
target: 'logger',
887-
transform({ values: [value] }) {
888-
return new LegacyLogger('MongoClient', { loggerLevel: value as LegacyLoggerLevel });
889-
}
890-
},
891872
maxConnecting: {
892873
default: 2,
893874
transform({ name, values: [value] }): number {

src/db.ts

+1-16
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import * as CONSTANTS from './constants';
66
import { AggregationCursor } from './cursor/aggregation_cursor';
77
import { ListCollectionsCursor } from './cursor/list_collections_cursor';
88
import { MongoAPIError, MongoInvalidArgumentError } from './error';
9-
import { Logger, LoggerOptions } from './logger';
109
import type { MongoClient, PkFactory } from './mongo_client';
1110
import type { TODO_NODE_3286 } from './mongo_types';
1211
import { AddUserOperation, AddUserOptions } from './operations/add_user';
@@ -64,8 +63,6 @@ const DB_OPTIONS_ALLOW_LIST = [
6463
'readConcern',
6564
'retryMiliSeconds',
6665
'numberOfRetries',
67-
'loggerLevel',
68-
'logger',
6966
'promoteBuffers',
7067
'promoteLongs',
7168
'bsonRegExp',
@@ -79,7 +76,6 @@ const DB_OPTIONS_ALLOW_LIST = [
7976
export interface DbPrivate {
8077
client: MongoClient;
8178
options?: DbOptions;
82-
logger: Logger;
8379
readPreference?: ReadPreference;
8480
pkFactory: PkFactory;
8581
readConcern?: ReadConcern;
@@ -89,7 +85,7 @@ export interface DbPrivate {
8985
}
9086

9187
/** @public */
92-
export interface DbOptions extends BSONSerializeOptions, WriteConcernOptions, LoggerOptions {
88+
export interface DbOptions extends BSONSerializeOptions, WriteConcernOptions {
9389
/** If the database authentication is dependent on another databaseName. */
9490
authSource?: string;
9591
/** Force server to assign _id values instead of driver. */
@@ -159,8 +155,6 @@ export class Db {
159155
client,
160156
// Options
161157
options,
162-
// Logger instance
163-
logger: new Logger('Db', options),
164158
// Unpack read preference
165159
readPreference: ReadPreference.fromOptions(options),
166160
// Merge bson options
@@ -756,15 +750,6 @@ export class Db {
756750

757751
return new ChangeStream<TSchema, TChange>(this, pipeline, resolveOptions(this, options));
758752
}
759-
760-
/** Return the db logger */
761-
getLogger(): Logger {
762-
return this.s.logger;
763-
}
764-
765-
get logger(): Logger {
766-
return this.s.logger;
767-
}
768753
}
769754

770755
// TODO(NODE-3484): Refactor into MongoDBNamespace

src/gridfs/index.ts

-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import type { Collection } from '../collection';
33
import type { FindCursor } from '../cursor/find_cursor';
44
import type { Db } from '../db';
55
import { MongoRuntimeError } from '../error';
6-
import type { Logger } from '../logger';
76
import { Filter, TypedEventEmitter } from '../mongo_types';
87
import type { ReadPreference } from '../read_preference';
98
import type { Sort } from '../sort';
@@ -225,9 +224,4 @@ export class GridFSBucket extends TypedEventEmitter<GridFSBucketEvents> {
225224
await this.s._chunksCollection.drop();
226225
}, callback);
227226
}
228-
229-
/** Get the Db scoped logger. */
230-
getLogger(): Logger {
231-
return this.s.db.s.logger;
232-
}
233227
}

src/index.ts

-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { Db } from './db';
1212
import { GridFSBucket } from './gridfs';
1313
import { GridFSBucketReadStream } from './gridfs/download';
1414
import { GridFSBucketWriteStream } from './gridfs/upload';
15-
import { Logger } from './logger';
1615
import { MongoClient } from './mongo_client';
1716
import { CancellationToken } from './mongo_types';
1817
import { ClientSession } from './sessions';
@@ -86,7 +85,6 @@ export {
8685
GridFSBucketWriteStream,
8786
ListCollectionsCursor,
8887
ListIndexesCursor,
89-
Logger,
9088
MongoClient,
9189
OrderedBulkOperation,
9290
UnorderedBulkOperation
@@ -101,7 +99,6 @@ export { CURSOR_FLAGS } from './cursor/abstract_cursor';
10199
export { AutoEncryptionLoggerLevel } from './deps';
102100
export { MongoErrorLabel } from './error';
103101
export { ExplainVerbosity } from './explain';
104-
export { LoggerLevel } from './logger';
105102
export { ServerApiVersion } from './mongo_client';
106103
export { ReturnDocument } from './operations/find_and_modify';
107104
export { ProfilingLevel } from './operations/set_profiling_level';
@@ -269,7 +266,6 @@ export type {
269266
} from './gridfs/download';
270267
export type { GridFSBucketEvents, GridFSBucketOptions, GridFSBucketPrivate } from './gridfs/index';
271268
export type { GridFSBucketWriteStreamOptions, GridFSChunk } from './gridfs/upload';
272-
export type { LoggerFunction, LoggerOptions } from './logger';
273269
export type {
274270
Auth,
275271
DriverInfo,

0 commit comments

Comments
 (0)