Skip to content

Commit 15b222b

Browse files
committed
Merge remote-tracking branch 'origin/main' into MONGOSH-1090-get-log-path
2 parents 15ee778 + 58710cf commit 15b222b

File tree

8 files changed

+167
-71
lines changed

8 files changed

+167
-71
lines changed

THIRD_PARTY_NOTICES.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
The following third-party software is used by and included in **mongosh**.
2-
This document was automatically generated on Wed Feb 12 2025.
2+
This document was automatically generated on Thu Feb 13 2025.
33

44
## List of dependencies
55

@@ -333,7 +333,7 @@ Package|Version|License
333333
**[mongodb-client-encryption](#d8efb4ae363035b677f38203b1acc7b0d69b22f13b17e95d09d151bf9928072a)**|6.1.1|Apache-2.0
334334
**[mongodb-connection-string-url](#2e1146256a89ebd24e3398881e03807fe363d58444e6b7952ea50bd6108707bc)**|3.0.1|Apache-2.0
335335
**[mongodb-crypt-library-version](#003bd2892d6f6fdac0613ba8f9a2fbb054ddd1c26901e1d2fc7e83861b21cf4d)**|1.0.5|Apache-2.0
336-
**[mongodb-log-writer](#0ea266b0fdd89dc0e20fe8fce081aaceb79e60918c606b3ab6e8b3978aa36ab5)**|2.3.0|Apache-2.0
336+
**[mongodb-log-writer](#861a6f7bbd07f1fc008955cc04714e6aa3e540a7449a2ab621b7dae0ad51ff96)**|2.3.1|Apache-2.0
337337
**[mongodb-redact](#6fe8cef9beca5f3e1e3e999f47975ae99dcf4488419b28fc6d5eafc436081623)**|1.1.5|Apache-2.0
338338
**[mongodb](#cb726cf7a5329fc15d51574a4bc2e29682afe46afb788a94370b09643ab98a72)**|6.12.0|Apache-2.0
339339
**[ms](#484b814b85d5028e34246147c8fc901d33570202bd7cdc3703c0ed1078eba0aa)**|2.0.0|MIT
@@ -27372,8 +27372,8 @@ License files:
2737227372

2737327373

2737427374

27375-
<a id="0ea266b0fdd89dc0e20fe8fce081aaceb79e60918c606b3ab6e8b3978aa36ab5"></a>
27376-
### [mongodb-log-writer](https://www.npmjs.com/package/mongodb-log-writer) (version 2.3.0)
27375+
<a id="861a6f7bbd07f1fc008955cc04714e6aa3e540a7449a2ab621b7dae0ad51ff96"></a>
27376+
### [mongodb-log-writer](https://www.npmjs.com/package/mongodb-log-writer) (version 2.3.1)
2737727377
License tags: Apache-2.0
2737827378

2737927379
License files:

package-lock.json

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/cli-repl/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
"is-recoverable-error": "^1.0.3",
8686
"js-yaml": "^4.1.0",
8787
"mongodb-connection-string-url": "^3.0.1",
88-
"mongodb-log-writer": "^2.3.0",
88+
"mongodb-log-writer": "^2.3.1",
8989
"numeral": "^2.0.6",
9090
"pretty-repl": "^4.0.1",
9191
"semver": "^7.5.4",

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

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,7 +1444,7 @@ describe('CliRepl', function () {
14441444
});
14451445

14461446
const customLogLocation = useTmpdir();
1447-
it('can set the log location', async function () {
1447+
it('can set the log location and uses a prefix', async function () {
14481448
cliRepl.config.logLocation = customLogLocation.path;
14491449
await cliRepl.start(await testServer.connectionString(), {});
14501450

@@ -1454,7 +1454,26 @@ describe('CliRepl', function () {
14541454
expect(cliRepl.logWriter?.logFilePath).equals(
14551455
path.join(
14561456
customLogLocation.path,
1457-
(cliRepl.logWriter?.logId as string) + '_log'
1457+
'mongosh_' + (cliRepl.logWriter?.logId as string) + '_log'
1458+
)
1459+
);
1460+
});
1461+
1462+
it('uses a prefix even if the custom location is the same as the home location', async function () {
1463+
// This is a corner case where the custom location is the same as the home location.
1464+
// The prefix is still added to the log file name for consistency. If the user needs
1465+
// the default behavior for the log names, they should instead set the location to undefined.
1466+
const customLogHomePath = cliRepl.shellHomeDirectory.localPath('.');
1467+
cliRepl.config.logLocation = customLogHomePath;
1468+
await cliRepl.start(await testServer.connectionString(), {});
1469+
1470+
expect(await cliRepl.getConfig('logLocation')).equals(
1471+
customLogHomePath
1472+
);
1473+
expect(cliRepl.logWriter?.logFilePath).equals(
1474+
path.join(
1475+
customLogHomePath,
1476+
'mongosh_' + (cliRepl.logWriter?.logId as string) + '_log'
14581477
)
14591478
);
14601479
expect(cliRepl.getLogPath()).equals(

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,10 +262,11 @@ export class CliRepl implements MongoshIOProvider {
262262
throw new Error('Logging and telemetry not setup');
263263
}
264264

265+
const customLogLocation = await this.getConfig('logLocation');
266+
265267
this.logManager ??= new MongoLogManager({
266-
directory:
267-
(await this.getConfig('logLocation')) ||
268-
this.shellHomeDirectory.localPath('.'),
268+
directory: customLogLocation || this.shellHomeDirectory.localPath('.'),
269+
prefix: customLogLocation ? 'mongosh_' : undefined,
269270
retentionDays: await this.getConfig('logRetentionDays'),
270271
gzip: await this.getConfig('logCompressionEnabled'),
271272
maxLogFileCount: await this.getConfig('logMaxFileCount'),

packages/e2e-tests/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"strip-ansi": "^6.0.0"
3434
},
3535
"devDependencies": {
36-
"mongodb-log-writer": "^2.3.0",
36+
"mongodb-log-writer": "^2.3.1",
3737
"@mongodb-js/eslint-config-mongosh": "^1.0.0",
3838
"@mongodb-js/oidc-mock-provider": "^0.10.2",
3939
"@mongodb-js/prettier-config-devtools": "^1.0.1",

0 commit comments

Comments
 (0)