Skip to content

Commit 8a25ea2

Browse files
fix: add user provided transport to the logger (#543)
1 parent 9d00594 commit 8a25ea2

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

handwritten/logging-winston/src/middleware/express.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ export async function makeMiddleware(
4747
const options = {logName: 'winston_log', ...optionsOrTransport};
4848

4949
transport = new LoggingWinston(options);
50-
logger.add(transport);
5150
} else {
5251
transport = optionsOrTransport;
5352
}
53+
logger.add(transport);
5454

5555
const auth = transport.common.stackdriverLog.logging.auth;
5656
const [env, projectId] = await Promise.all([

handwritten/logging-winston/test/middleware/express.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,13 @@ describe('middleware/express', () => {
113113
assert.strictEqual(logger.transports[0], transport);
114114
});
115115

116+
it('should add a user provided transport to the logger', async () => {
117+
const t = new FakeLoggingWinston({});
118+
await makeMiddleware(logger, t);
119+
assert.strictEqual(logger.transports.length, 1);
120+
assert.strictEqual(logger.transports[0], t);
121+
});
122+
116123
it('should create a transport with the correct logName', async () => {
117124
await makeMiddleware(logger);
118125
assert.ok(passedOptions);

0 commit comments

Comments
 (0)