Skip to content

Commit bad1206

Browse files
committed
address comments
1 parent 419d42c commit bad1206

2 files changed

Lines changed: 17 additions & 18 deletions

File tree

packages/logging-bunyan/src/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,11 @@ LoggingBunyan.prototype.stream = function(level) {
130130
/**
131131
* Format a bunyan record into a Stackdriver log entry.
132132
*
133-
* @param {object} - Bunyan log record.
133+
* @param {object} record - Bunyan log record.
134134
*
135135
* @private
136136
*/
137-
LoggingBunyan.prototype._formatEntry = function(record) {
137+
LoggingBunyan.prototype.formatEntry_ = function(record) {
138138
if (typeof record === 'string') {
139139
throw new Error(
140140
'@google-cloud/logging-bunyan only works as a raw bunyan stream type.'
@@ -182,7 +182,7 @@ LoggingBunyan.prototype._formatEntry = function(record) {
182182
* @private
183183
*/
184184
LoggingBunyan.prototype._write = function(record, encoding, callback) {
185-
var entry = this._formatEntry(record);
185+
var entry = this.formatEntry_(record);
186186
var level = BUNYAN_TO_STACKDRIVER[record.level];
187187
this.log_[level](entry, callback);
188188
};

packages/logging-bunyan/test/index.js

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,16 @@ describe('logging-bunyan', function() {
3838
};
3939
}
4040

41-
function fakeWritable(options) {
41+
function FakeWritable(options) {
4242
fakeWritableOptions_ = options;
4343
}
4444

45-
fakeWritable.prototype.write = function(chunk, encoding, callback) {
45+
FakeWritable.prototype.write = function(chunk, encoding, callback) {
4646
setImmediate(callback);
4747
};
4848

4949
var fakeStream = {
50-
Writable: fakeWritable
50+
Writable: FakeWritable
5151
};
5252

5353
var LoggingBunyanCached;
@@ -90,7 +90,7 @@ describe('logging-bunyan', function() {
9090
});
9191

9292
it('should be an object mode Writable', function() {
93-
assert(loggingBunyan instanceof fakeWritable);
93+
assert(loggingBunyan instanceof FakeWritable);
9494
assert.deepStrictEqual(fakeWritableOptions_, { objectMode: true });
9595
});
9696

@@ -126,11 +126,11 @@ describe('logging-bunyan', function() {
126126
});
127127
});
128128

129-
describe('_formatEntry', function() {
129+
describe('formatEntry_', function() {
130130

131131
it('should throw an error if record is a string', function() {
132132
assert.throws(function() {
133-
loggingBunyan._formatEntry('string record');
133+
loggingBunyan.formatEntry_('string record');
134134
}, new RegExp(
135135
'@google-cloud/logging-bunyan only works as a raw bunyan stream type.'
136136
));
@@ -146,7 +146,7 @@ describe('logging-bunyan', function() {
146146
done();
147147
};
148148

149-
loggingBunyan._formatEntry(RECORD);
149+
loggingBunyan.formatEntry_(RECORD);
150150
});
151151

152152
it('should rename the msg property to message', function(done) {
@@ -158,7 +158,7 @@ describe('logging-bunyan', function() {
158158
done();
159159
};
160160

161-
loggingBunyan._formatEntry(recordWithMsg);
161+
loggingBunyan.formatEntry_(recordWithMsg);
162162
});
163163

164164
it('should inject the error stack as the message', function(done) {
@@ -181,7 +181,7 @@ describe('logging-bunyan', function() {
181181
done();
182182
};
183183

184-
loggingBunyan._formatEntry(record);
184+
loggingBunyan.formatEntry_(record);
185185
});
186186

187187
it('should leave message property intact when present', function(done) {
@@ -198,7 +198,7 @@ describe('logging-bunyan', function() {
198198
done();
199199
};
200200

201-
loggingBunyan._formatEntry(record);
201+
loggingBunyan.formatEntry_(record);
202202
});
203203
});
204204

@@ -211,7 +211,7 @@ describe('logging-bunyan', function() {
211211
});
212212

213213
it('should format the record', function(done) {
214-
loggingBunyan._formatEntry = function(record) {
214+
loggingBunyan.formatEntry_ = function(record) {
215215
assert.strictEqual(record, RECORD);
216216
done();
217217
};
@@ -229,16 +229,15 @@ describe('logging-bunyan', function() {
229229

230230
LoggingBunyan.BUNYAN_TO_STACKDRIVER[RECORD.level] = customLevel;
231231

232-
loggingBunyan.log_[customLevel] = function(entry_) {
232+
loggingBunyan.log_[customLevel] = function(entry_, callback) {
233233
assert.strictEqual(entry_, entry);
234-
done();
234+
callback(); // done()
235235
};
236236

237-
loggingBunyan._write(RECORD, '', assert.ifError);
237+
loggingBunyan._write(RECORD, '', done);
238238
});
239239
});
240240

241-
242241
describe('BUNYAN_TO_STACKDRIVER', function() {
243242
it('should correctly map to Stackdriver Logging levels', function() {
244243
assert.deepEqual(LoggingBunyan.BUNYAN_TO_STACKDRIVER, {

0 commit comments

Comments
 (0)