Skip to content
This repository has been archived by the owner on Dec 14, 2022. It is now read-only.

Commit

Permalink
fix: use "fast-safe-stringify" lib to handle circular json
Browse files Browse the repository at this point in the history
  • Loading branch information
vladholubiev committed Feb 22, 2019
1 parent 63cfe55 commit 0486cca
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const Transport = require('winston-transport');
const tls = require('tls');
const Transport = require('winston-transport');
const safeStringify = require('fast-safe-stringify');

const config = {
host: 'intake.logs.datadoghq.com',
Expand Down Expand Up @@ -45,7 +46,7 @@ module.exports = class DatadogTransport extends Transport {
// Merge the metadata with the log
const logEntry = Object.assign({}, this.metadata, info);

socket.write(`${config.apiKey} ${JSON.stringify(logEntry)}\r\n`, () => {
socket.write(`${config.apiKey} ${safeStringify(logEntry)}\r\n`, () => {
socket.end();

return callback();
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"datadog logs"
],
"dependencies": {
"fast-safe-stringify": "2.0.6",
"winston-transport": "4.3.0"
},
"devDependencies": {
Expand Down

0 comments on commit 0486cca

Please sign in to comment.