Skip to content

Commit

Permalink
Merge pull request #4 from vbogdanov/master
Browse files Browse the repository at this point in the history
a fix for circular references in the record
  • Loading branch information
mlazarov authored Sep 27, 2016
2 parents cd290ba + 4d6b159 commit b385e68
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/bunyan-stackdriver.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var util = require('util');
var logging = require('@google-cloud/logging');
var Writable = require('stream').Writable;
var destroyCircular = require('destroy-circular');

const nameFromLevel = {
10: 'trace',
Expand Down Expand Up @@ -88,6 +89,8 @@ BunyanStackDriver.prototype._write = function write(record, encoding, callback)
timestamp = record.time;
}

//This might slow down the logging a bit, but will protect against circular references
record = destroyCircular(record);
strictJSON(record);

var entry = this.log.entry(this.resource, record);
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
},
"homepage": "https://github.com/mlazarov/bunyan-stackdriver",
"dependencies": {
"@google-cloud/logging": "^0.1.1"
"@google-cloud/logging": "^0.1.1",
"destroy-circular": "^1.1.0"
},
"devDependencies": {
"bunyan": "^1.3.3"
Expand Down

0 comments on commit b385e68

Please sign in to comment.