class
Entry
Source: entry.
Create an entry object to define new data to insert into a log.
Method
new Entry([metadata], data)
Example
const {Logging} = require('@google-cloud/logging');
const logging = new Logging();
const syslog = logging.log('syslog');
const metadata = {
resource: {
type: 'gce_instance',
labels: {
zone: 'global',
instance_id: '3'
}
}
};
const entry = syslog.entry(metadata, {
delegate: 'my_username'
});
syslog.alert(entry, (err, apiResponse) => {
if (!err) {
// Log entry inserted successfully.
}
});
//-
// You will also receive `Entry` objects when using
// Logging#getEntries() and Log#getEntries().
//-
logging.getEntries((err, entries) => {
if (!err) {
// entries[0].data = The data value from the log entry.
}
});
Parameters
| Name | Type | Optional | Description |
|---|---|---|---|
|
metadata |
|
Yes |
See a LogEntry Resource. Value can be null. |
|
data |
|
|
The data to use as the value for this log entry.
|
- See also
Properties
data object
metadata object
Properties
| Name | Type | Optional | Description |
|---|---|---|---|
|
timestamp |
Date |
|
|
|
insertId |
number |
|
Method
toJSON([options])
Serialize an entry to the format the API expects.
Parameters
| Name | Type | Optional | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
options |
object |
Yes |
Configuration object. Values in
|