Skip to content

Commit d42d455

Browse files
committed
fix: rename readReplLogfile to readReplLogFile and remove unnecessary log undefined check
1 parent e385c9e commit d42d455

File tree

6 files changed

+20
-22
lines changed

6 files changed

+20
-22
lines changed

packages/cli-repl/src/cli-repl.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
import {
1919
expect,
2020
fakeTTYProps,
21-
readReplLogfile,
21+
readReplLogFile,
2222
tick,
2323
useTmpdir,
2424
waitBus,
@@ -56,7 +56,7 @@ describe('CliRepl', function () {
5656
async function log(): Promise<any[]> {
5757
if (!cliRepl.logWriter?.logFilePath) return [];
5858
await cliRepl.logWriter.flush(); // Ensure any pending data is written first
59-
return readReplLogfile(cliRepl.logWriter.logFilePath);
59+
return readReplLogFile(cliRepl.logWriter.logFilePath);
6060
}
6161

6262
async function startWithExpectedImmediateExit(
@@ -1580,7 +1580,7 @@ describe('CliRepl', function () {
15801580
input.write('db.hello()\n');
15811581
input.write('exit\n');
15821582
await waitBus(cliRepl.bus, 'mongosh:closed');
1583-
const flushEntry = (await readReplLogfile(logFilePath)).find(
1583+
const flushEntry = (await readReplLogFile(logFilePath)).find(
15841584
(entry: any) => entry.id === 1_000_000_045
15851585
);
15861586
expect(flushEntry.attr.flushError).to.equal(null);

packages/cli-repl/test/repl-helpers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ const fakeTTYProps: Partial<ReadStream & WriteStream> = {
8787
},
8888
};
8989

90-
async function readReplLogfile(
90+
async function readReplLogFile(
9191
logPath?: string | null | undefined
9292
): Promise<any[]> {
9393
if (!logPath) return [];
@@ -107,5 +107,5 @@ export {
107107
waitEval,
108108
waitCompletion,
109109
fakeTTYProps,
110-
readReplLogfile,
110+
readReplLogFile,
111111
};

packages/e2e-tests/test/e2e-tls.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { startTestServer } from '../../../testing/integration-testing-hooks';
55
import {
66
useTmpdir,
77
setTemporaryHomeDirectory,
8-
readReplLogfile,
8+
readReplLogFile,
99
getCertPath,
1010
connectionStringWithLocalhost,
1111
} from './repl-helpers';
@@ -241,7 +241,7 @@ describe('e2e TLS', function () {
241241
expect(prompt.state).to.equal('prompt');
242242

243243
const logPath = path.join(logBasePath, `${shell.logId}_log`);
244-
const logContents = await readReplLogfile(logPath);
244+
const logContents = await readReplLogFile(logPath);
245245
expect(
246246
logContents.find((line) => line.id.__value === 1_000_000_049)?.attr
247247
.asyncFallbackError
@@ -278,7 +278,7 @@ describe('e2e TLS', function () {
278278
expect(prompt.state).to.equal('prompt');
279279

280280
const logPath = path.join(logBasePath, `${shell.logId}_log`);
281-
const logContents = await readReplLogfile(logPath);
281+
const logContents = await readReplLogFile(logPath);
282282
expect(
283283
logContents.find((line) => line.id.__value === 1_000_000_049)?.attr
284284
.asyncFallbackError
@@ -308,7 +308,7 @@ describe('e2e TLS', function () {
308308
expect(prompt.state).to.equal('exit');
309309

310310
const logPath = path.join(logBasePath, `${shell.logId}_log`);
311-
const logContents = await readReplLogfile(logPath);
311+
const logContents = await readReplLogFile(logPath);
312312
expect(logContents.find((line) => line.id.__value === 1_000_000_049)).to
313313
.exist;
314314
});

packages/e2e-tests/test/e2e.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { promises as fs, createReadStream } from 'fs';
1414
import { promisify } from 'util';
1515
import path from 'path';
1616
import os from 'os';
17-
import { readReplLogfile, setTemporaryHomeDirectory } from './repl-helpers';
17+
import { readReplLogFile, setTemporaryHomeDirectory } from './repl-helpers';
1818
import { bson } from '@mongosh/service-provider-core';
1919
import type { Server as HTTPServer } from 'http';
2020
import { createServer as createHTTPServer } from 'http';
@@ -1398,7 +1398,7 @@ describe('e2e', function () {
13981398
throw new Error('Shell does not have a logId associated with it');
13991399
}
14001400
const logPath = path.join(logBasePath, `${shell.logId}_log`);
1401-
return readReplLogfile<T>(logPath);
1401+
return readReplLogFile<T>(logPath);
14021402
};
14031403
startTestShell = async (...extraArgs: string[]) => {
14041404
const shell = this.startTestShell({

packages/e2e-tests/test/repl-helpers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function useTmpdir(): { readonly path: string } {
4949
};
5050
}
5151

52-
async function readReplLogfile<T extends MongoLogEntry>(
52+
async function readReplLogFile<T extends MongoLogEntry>(
5353
logPath: string
5454
): Promise<T[]> {
5555
return (await fs.readFile(logPath, 'utf8'))
@@ -165,7 +165,7 @@ async function connectionStringWithLocalhost(
165165
// eslint-disable-next-line mocha/no-exports
166166
export {
167167
useTmpdir,
168-
readReplLogfile,
168+
readReplLogFile,
169169
fakeExternalEditor,
170170
setTemporaryHomeDirectory,
171171
getCertPath,

packages/logging/src/logging-and-telemetry.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -325,15 +325,13 @@ class LoggingAndTelemetry implements MongoshLoggingAndTelemetry {
325325
metadata: unknown;
326326
};
327327

328-
if (this.log) {
329-
this.log[context === 'fatal' ? 'fatal' : 'error'](
330-
'MONGOSH',
331-
mongoLogId(1_000_000_006),
332-
context,
333-
`${mongoshError.name}: ${mongoshError.message}`,
334-
error
335-
);
336-
}
328+
this.log[context === 'fatal' ? 'fatal' : 'error'](
329+
'MONGOSH',
330+
mongoLogId(1_000_000_006),
331+
context,
332+
`${mongoshError.name}: ${mongoshError.message}`,
333+
error
334+
);
337335

338336
if (error.name.includes('Mongosh')) {
339337
this.analytics.track({

0 commit comments

Comments
 (0)