Skip to content

Commit 355650e

Browse files
domiinswbt
authored andcommitted
Add the replacer option to the HTTP transport
Support custom stringify replacer when sending logs via HTTP transport. Usage of the `format.json` with the custom replacer does not work with HTTP transport since the message symlink (which is mutated) is not sent in the request.
1 parent 440babc commit 355650e

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

lib/winston/transports/http.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,6 @@ module.exports = class Http extends TransportStream {
262262
req.on('response', res => (
263263
res.on('end', () => callback(null, res)).resume()
264264
));
265-
req.end(Buffer.from(jsonStringify(options), 'utf8'));
265+
req.end(Buffer.from(jsonStringify(options, this.options.replacer), 'utf8'));
266266
}
267267
};

lib/winston/transports/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ declare namespace winston {
6262
batch?: boolean;
6363
batchInterval?: number;
6464
batchCount?: number;
65+
replacer?: (key: string, value: any) => any;
6566
}
6667

6768
interface HttpTransportInstance extends Transport {

0 commit comments

Comments
 (0)