Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(NODE-4817)!: remove legacy logger #3518

Merged
merged 23 commits into from
Jan 23, 2023
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
baea3b2
fix(NODE-4817): Remove legacy logger
W-A-James Jan 10, 2023
bf2e5b8
test(NODE-4817): Fix
W-A-James Jan 10, 2023
1888844
fix(NODE-4817): remove reference to logger
W-A-James Jan 11, 2023
06fe95a
fix(NODE-4817): Remove logger.ts
W-A-James Jan 13, 2023
b61d313
fix(NODE-4817): Remove reference to logger module
W-A-James Jan 13, 2023
f99a285
fix(NODE-4817): Add TODOS
W-A-James Jan 19, 2023
9ca43db
Merge branch 'main' into NODE-4817/remove-legacy-logger
W-A-James Jan 19, 2023
e4b7694
test(NODE-4817): Remove reference to LoggerLevel
W-A-James Jan 19, 2023
77a6d36
Merge branch 'NODE-4817/remove-legacy-logger' of github.com:mongodb/n…
W-A-James Jan 19, 2023
390b4c9
test(NODE-4817): Add todo comments
W-A-James Jan 19, 2023
cdc6c08
fix(NODE-4817): Remove unneeded code
W-A-James Jan 19, 2023
f84d4b3
Merge branch 'main' into NODE-4817/remove-legacy-logger
durran Jan 20, 2023
0799e26
fix(NODE-4817): Remove unneeded comments and code
W-A-James Jan 20, 2023
2ac3dfe
fix(NODE-4817): remove reference to deleted method
W-A-James Jan 20, 2023
8f79254
test(NODE-4817): remove reference to deleted method
W-A-James Jan 20, 2023
5a1d8fe
Merge branch 'main' into NODE-4817/remove-legacy-logger
W-A-James Jan 20, 2023
b0616e8
fix(NODE-4817): Remove unused code
W-A-James Jan 23, 2023
531f004
fix(NODE-4817): Change promise handler to unconditionally return null
W-A-James Jan 23, 2023
c8b865d
Merge branch 'main' into NODE-4817/remove-legacy-logger
W-A-James Jan 23, 2023
dd51e0f
fix(NODE-4817): remove unneeded argument in dummy promise error handler
W-A-James Jan 23, 2023
42c2daf
Merge branch 'NODE-4817/remove-legacy-logger' of github.com:mongodb/n…
W-A-James Jan 23, 2023
e64c821
style(NODE-4817): Remove TODO comment
W-A-James Jan 23, 2023
4f0a43c
style(NODE-4817): link to new ticket
W-A-James Jan 23, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions src/cmap/connection_pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {
MongoRuntimeError,
MongoServerError
} from '../error';
import { Logger } from '../logger';
import { CancellationToken, TypedEventEmitter } from '../mongo_types';
import type { Server } from '../sdam/server';
import { Callback, eachAsync, List, makeCounter } from '../utils';
Expand Down Expand Up @@ -52,8 +51,6 @@ import { ConnectionPoolMetrics } from './metrics';
/** @internal */
const kServer = Symbol('server');
/** @internal */
const kLogger = Symbol('logger');
/** @internal */
const kConnections = Symbol('connections');
/** @internal */
const kPending = Symbol('pending');
Expand Down Expand Up @@ -140,7 +137,6 @@ export class ConnectionPool extends TypedEventEmitter<ConnectionPoolEvents> {
options: Readonly<ConnectionPoolOptions>;
[kPoolState]: typeof PoolState[keyof typeof PoolState];
[kServer]: Server;
[kLogger]: Logger;
[kConnections]: List<Connection>;
[kPending]: number;
[kCheckedOut]: Set<Connection>;
Expand Down Expand Up @@ -239,7 +235,6 @@ export class ConnectionPool extends TypedEventEmitter<ConnectionPoolEvents> {

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

connect(connectOptions, (err, connection) => {
if (err || !connection) {
this[kLogger].debug(`connection attempt failed with error [${JSON.stringify(err)}]`);
this[kPending]--;
this.emit(
ConnectionPool.CONNECTION_CLOSED,
Expand Down
15 changes: 1 addition & 14 deletions src/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { FindCursor } from './cursor/find_cursor';
import { ListIndexesCursor } from './cursor/list_indexes_cursor';
import type { Db } from './db';
import { MongoInvalidArgumentError } from './error';
import type { Logger, LoggerOptions } from './logger';
import type { PkFactory } from './mongo_client';
import type {
Filter,
Expand Down Expand Up @@ -105,10 +104,7 @@ export interface ModifyResult<TSchema = Document> {
}

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

/** Get the db scoped logger */
getLogger(): Logger {
dariakp marked this conversation as resolved.
Show resolved Hide resolved
return this.s.db.s.logger;
}

get logger(): Logger {
return this.s.db.s.logger;
}

/**
* An estimated count of matching documents in the db to a filter.
*
Expand Down
19 changes: 0 additions & 19 deletions src/connection_string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
MongoMissingCredentialsError,
MongoParseError
} from './error';
import { Logger as LegacyLogger, LoggerLevel as LegacyLoggerLevel } from './logger';
import {
DriverInfo,
MongoClient,
Expand Down Expand Up @@ -870,24 +869,6 @@ export const OPTIONS = {
default: 15,
type: 'uint'
},
logger: {
default: new LegacyLogger('MongoClient'),
transform({ values: [value] }) {
if (value instanceof LegacyLogger) {
return value;
}
emitWarning('Alternative loggers might not be supported');
// TODO: make Logger an interface that others can implement, make usage consistent in driver
// DRIVERS-1204
return;
}
},
loggerLevel: {
target: 'logger',
transform({ values: [value] }) {
return new LegacyLogger('MongoClient', { loggerLevel: value as LegacyLoggerLevel });
}
},
maxConnecting: {
default: 2,
transform({ name, values: [value] }): number {
Expand Down
17 changes: 1 addition & 16 deletions src/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import * as CONSTANTS from './constants';
import { AggregationCursor } from './cursor/aggregation_cursor';
import { ListCollectionsCursor } from './cursor/list_collections_cursor';
import { MongoAPIError, MongoInvalidArgumentError } from './error';
import { Logger, LoggerOptions } from './logger';
import type { MongoClient, PkFactory } from './mongo_client';
import type { TODO_NODE_3286 } from './mongo_types';
import { AddUserOperation, AddUserOptions } from './operations/add_user';
Expand Down Expand Up @@ -64,8 +63,6 @@ const DB_OPTIONS_ALLOW_LIST = [
'readConcern',
'retryMiliSeconds',
'numberOfRetries',
'loggerLevel',
'logger',
'promoteBuffers',
'promoteLongs',
'bsonRegExp',
Expand All @@ -79,7 +76,6 @@ const DB_OPTIONS_ALLOW_LIST = [
export interface DbPrivate {
client: MongoClient;
options?: DbOptions;
logger: Logger;
readPreference?: ReadPreference;
pkFactory: PkFactory;
readConcern?: ReadConcern;
Expand All @@ -89,7 +85,7 @@ export interface DbPrivate {
}

/** @public */
export interface DbOptions extends BSONSerializeOptions, WriteConcernOptions, LoggerOptions {
export interface DbOptions extends BSONSerializeOptions, WriteConcernOptions {
/** If the database authentication is dependent on another databaseName. */
authSource?: string;
/** Force server to assign _id values instead of driver. */
Expand Down Expand Up @@ -159,8 +155,6 @@ export class Db {
client,
// Options
options,
// Logger instance
logger: new Logger('Db', options),
// Unpack read preference
readPreference: ReadPreference.fromOptions(options),
// Merge bson options
Expand Down Expand Up @@ -756,15 +750,6 @@ export class Db {

return new ChangeStream<TSchema, TChange>(this, pipeline, resolveOptions(this, options));
}

/** Return the db logger */
getLogger(): Logger {
dariakp marked this conversation as resolved.
Show resolved Hide resolved
return this.s.logger;
}

get logger(): Logger {
return this.s.logger;
}
}

// TODO(NODE-3484): Refactor into MongoDBNamespace
Expand Down
6 changes: 0 additions & 6 deletions src/gridfs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import type { Collection } from '../collection';
import type { FindCursor } from '../cursor/find_cursor';
import type { Db } from '../db';
import { MongoRuntimeError } from '../error';
import type { Logger } from '../logger';
import { Filter, TypedEventEmitter } from '../mongo_types';
import type { ReadPreference } from '../read_preference';
import type { Sort } from '../sort';
Expand Down Expand Up @@ -225,9 +224,4 @@ export class GridFSBucket extends TypedEventEmitter<GridFSBucketEvents> {
await this.s._chunksCollection.drop();
}, callback);
}

/** Get the Db scoped logger. */
getLogger(): Logger {
dariakp marked this conversation as resolved.
Show resolved Hide resolved
return this.s.db.s.logger;
}
}
4 changes: 0 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { Db } from './db';
import { GridFSBucket } from './gridfs';
import { GridFSBucketReadStream } from './gridfs/download';
import { GridFSBucketWriteStream } from './gridfs/upload';
import { Logger } from './logger';
import { MongoClient } from './mongo_client';
import { CancellationToken } from './mongo_types';
import { ClientSession } from './sessions';
Expand Down Expand Up @@ -86,7 +85,6 @@ export {
GridFSBucketWriteStream,
ListCollectionsCursor,
ListIndexesCursor,
Logger,
MongoClient,
OrderedBulkOperation,
UnorderedBulkOperation
Expand All @@ -101,7 +99,6 @@ export { CURSOR_FLAGS } from './cursor/abstract_cursor';
export { AutoEncryptionLoggerLevel } from './deps';
export { MongoErrorLabel } from './error';
export { ExplainVerbosity } from './explain';
export { LoggerLevel } from './logger';
export { ServerApiVersion } from './mongo_client';
export { BSONType } from './mongo_types';
export { ReturnDocument } from './operations/find_and_modify';
Expand Down Expand Up @@ -270,7 +267,6 @@ export type {
} from './gridfs/download';
export type { GridFSBucketEvents, GridFSBucketOptions, GridFSBucketPrivate } from './gridfs/index';
export type { GridFSBucketWriteStreamOptions, GridFSChunk } from './gridfs/upload';
export type { LoggerFunction, LoggerOptions } from './logger';
export type {
Auth,
DriverInfo,
Expand Down
Loading