Skip to content

Commit

Permalink
Add the replacer option to the HTTP transport
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
domiins authored and wbt committed Jun 23, 2022
1 parent 440babc commit 355650e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/winston/transports/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,6 @@ module.exports = class Http extends TransportStream {
req.on('response', res => (
res.on('end', () => callback(null, res)).resume()
));
req.end(Buffer.from(jsonStringify(options), 'utf8'));
req.end(Buffer.from(jsonStringify(options, this.options.replacer), 'utf8'));
}
};
1 change: 1 addition & 0 deletions lib/winston/transports/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ declare namespace winston {
batch?: boolean;
batchInterval?: number;
batchCount?: number;
replacer?: (key: string, value: any) => any;
}

interface HttpTransportInstance extends Transport {
Expand Down

0 comments on commit 355650e

Please sign in to comment.