Skip to content
This repository was archived by the owner on Mar 11, 2026. It is now read-only.

Commit 89408b0

Browse files
authored
fix: Add LogSyncOptions parameter to Logging.logSync() API (#1307)
1 parent 005cfec commit 89408b0

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

src/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ import {
4949
assignSeverityToEntries,
5050
} from './utils/log-common';
5151
import {Log, GetEntriesRequest, TailEntriesRequest, LogOptions} from './log';
52-
import {LogSync} from './log-sync';
52+
import {LogSync, LogSyncOptions} from './log-sync';
5353
import {Sink} from './sink';
5454
import {Duplex, PassThrough, Transform, Writable} from 'stream';
5555
import {google} from '../protos/protos';
@@ -1251,6 +1251,7 @@ class Logging {
12511251
*
12521252
* @param {string} name Name of the existing log.
12531253
* @param {object} transport An optional write stream.
1254+
* @param {LogSyncOptions} options An optional configuration object.
12541255
* @returns {LogSync}
12551256
*
12561257
* @example
@@ -1266,8 +1267,8 @@ class Logging {
12661267
* const log = logging.logSync('my-log');
12671268
* ```
12681269
*/
1269-
logSync(name: string, transport?: Writable) {
1270-
return new LogSync(this, name, transport);
1270+
logSync(name: string, transport?: Writable, options?: LogSyncOptions) {
1271+
return new LogSync(this, name, transport, options);
12711272
}
12721273

12731274
/**

test/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,6 +1234,18 @@ describe('Logging', () => {
12341234
assert.strictEqual(log.calledWith_[0], logging);
12351235
assert.strictEqual(log.calledWith_[1], NAME);
12361236
});
1237+
1238+
it('should pass useMessageField properly', () => {
1239+
const log = logging.logSync(NAME, undefined, {
1240+
useMessageField: false,
1241+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
1242+
}) as any;
1243+
assert(log instanceof FakeLog);
1244+
assert.strictEqual(log.calledWith_[0], logging);
1245+
assert.strictEqual(log.calledWith_[1], NAME);
1246+
assert.strictEqual(log.calledWith_[2], undefined);
1247+
assert.strictEqual(log.calledWith_[3].useMessageField, false);
1248+
});
12371249
});
12381250

12391251
describe('request', () => {

0 commit comments

Comments
 (0)