Skip to content

Commit b37c5cc

Browse files
feat: Add support for TransportStream options (#775)
* feat: Add support for TransportStream options * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * fix the link Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 42505e6 commit b37c5cc

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

handwritten/nodejs-logging-winston/src/index.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,16 @@ export interface Options extends LoggingOptions {
105105
* By default this value is true
106106
*/
107107
useMessageField?: boolean;
108+
109+
/**
110+
* Additional parameters for {@link TransportStream}. For more information on parameters,
111+
* please see [winston-transport](https://github.com/winstonjs/winston-transport/blob/0e5e4c0056188a74e24407ee066902fb113bd8de/index.js#L8).
112+
*/
113+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
114+
format?: any;
115+
silent?: boolean;
116+
handleExceptions?: boolean;
117+
handleRejections?: boolean;
108118
}
109119

110120
/**
@@ -196,6 +206,10 @@ export class LoggingWinston extends TransportStream {
196206
options = options || {};
197207
super({
198208
level: options.level,
209+
format: options.format,
210+
silent: options.silent,
211+
handleExceptions: options.handleExceptions,
212+
handleRejections: options.handleRejections,
199213
});
200214
this.common = new LoggingCommon(options);
201215
}

handwritten/nodejs-logging-winston/test/index.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,26 @@ describe('logging-winston', () => {
138138
OPTIONS.serviceContext
139139
);
140140
});
141+
142+
it('should pass all parameters to TransportStream', () => {
143+
const level = 'INFO';
144+
const format = 'FORMAT';
145+
const optionsWithTransportStreamparameters = Object.assign({}, OPTIONS, {
146+
level: level,
147+
format: format,
148+
silent: true,
149+
handleExceptions: true,
150+
handleRejections: false,
151+
});
152+
new loggingWinstonLib.LoggingWinston(
153+
optionsWithTransportStreamparameters
154+
);
155+
assert.strictEqual(fakeLoggingOptions_!.level, level);
156+
assert.strictEqual(fakeLoggingOptions_!.format, format);
157+
assert.strictEqual(fakeLoggingOptions_!.silent, true);
158+
assert.strictEqual(fakeLoggingOptions_!.handleExceptions, true);
159+
assert.strictEqual(fakeLoggingOptions_!.handleRejections, false);
160+
});
141161
});
142162

143163
describe('log', () => {

0 commit comments

Comments
 (0)