Skip to content

Commit 6e70027

Browse files
authored
add auto batching entries (#102)
1 parent 09dd369 commit 6e70027

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

docs/API.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ Type: `String` or `{ client_email: String, private_key: String }` *(optional)*
4040
Full path to the JSON file containing the Google Service Credentials,
4141
you can also use an object parameter with the client_email and the private_key instead of the path. Defaults to the GOOGLE_APPLICATION_CREDENTIALS environment variable. At least one has to be available.
4242

43-
4443
#### projectId
4544

4645
Type: `String` *(required)*
@@ -72,6 +71,10 @@ Type: Boolean *(optional)*
7271

7372
Set the gRPC fallback option for the Google Stackdriver API.
7473

74+
## Batching
75+
76+
Log entries will automatically be batched by the Google cloud logging library that's being used internally using a *fire and forget* meganism.
77+
7578
## Prefixing messages
7679

7780
Prefixing message is supported via a `prefix` property from the log data:
@@ -89,4 +92,4 @@ Will send the following JSON payload to Stackdriver:
8992
"message": "[foo] Info message"
9093
// ...
9194
}
92-
```
95+
```

src/stackdriver.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ function _getKey (log, data, k, keys) {
4242
return undefined
4343
}
4444

45+
function _noop () {}
46+
4547
module.exports.parseJsonStream = function () {
4648
return split2(_jsonParser)
4749
}
@@ -108,7 +110,8 @@ module.exports.toStackdriverStream = function (options = {}) {
108110
objectMode: true,
109111
write (chunk, encoding, callback) {
110112
const entry = log.entry(chunk.meta, chunk.data)
111-
log[chunk.meta.severity](entry, callback)
113+
log[chunk.meta.severity](entry, _noop)
114+
callback()
112115
}
113116
})
114117
return writableStream

0 commit comments

Comments
 (0)