Constructor
new Log(logging, name, optionsopt)
Parameters:
Name | Type | Attributes | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
logging |
Logging |
Logging instance. |
|||||||||||||
name |
string |
Name of the log. |
|||||||||||||
options |
object |
<optional> |
Configuration object. Properties
|
- See:
Members
name
name
Methods
getEntriesStream(queryopt) → {ReadableStream}
This method is a wrapper around {module:logging#getEntriesStream}, but with a filter specified to only return {module:logging/entry} objects from this log.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
query |
GetEntriesRequest |
<optional> |
Query object for listing entries. |
Returns:
Type | Description |
---|---|
ReadableStream |
A readable stream that emits Entry instances. |
Example
```
const {Logging} = require('@google-cloud/logging');
const logging = new Logging();
const log = logging.log('my-log');
log.getEntriesStream()
.on('error', console.error)
.on('data', entry => {
// `entry` is a Cloud Logging entry object.
// See the `data` property to read the data from the entry.
})
.on('end', function() {
// All entries retrieved.
});
//-
// If you anticipate many results, you can end a stream early to prevent
// unnecessary processing and API requests.
//-
log.getEntriesStream()
.on('data', function(entry) {
this.end();
});
```
tailEntries(queryopt) → {DuplexStream}
This method is a wrapper around {module:logging#tailEntries}, but with a filter specified to only return {module:logging/entry} objects from this log.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
query |
TailEntriesRequest |
<optional> |
Query object for tailing entries. |
Returns:
Type | Description |
---|---|
DuplexStream |
A duplex stream that emits TailEntriesResponses containing an array of Entry instances. |
Example
```
const {Logging} = require('@google-cloud/logging');
const logging = new Logging();
const log = logging.log('my-log');
log.tailEntries()
.on('error', console.error)
.on('data', resp => {
console.log(resp.entries);
console.log(resp.suppressionInfo);
})
.on('end', function() {
// All entries retrieved.
});
//-
// If you anticipate many results, you can end a stream early to prevent
// unnecessary processing and API requests.
//-
log.tailEntries()
.on('data', function(entry) {
this.end();
});
```