Entry
Create an entry object to define new data to insert into a log.
Constructor
Entry
new Entry(metadata, data)
Parameter |
|
---|---|
metadata |
Optional object See a LogEntry Resource. Value may be null. |
data |
(object or string)
The data to use as the value for this log entry.
|
- See also
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.
}
});
Properties
data
object
metadata
object
Properties
Parameter |
|
---|---|
timestamp |
Date |
insertId |
number |
Method
toJSON
toJSON(options)
Serialize an entry to the format the API expects.
Parameter |
|||||
---|---|---|---|---|---|
options |
Optional object Configuration object. Values in
|