Entry

Entry

Create an entry object to define new data to insert into a log.

Note, Cloud Logging Quotas and limits dictates that the maximum log entry size, including all LogEntry Resource properties, cannot exceed approximately 256 KB.

Constructor

new Entry(metadataopt, nullable, data)

Parameters:
Name Type Attributes Description
metadata object <optional>
<nullable>

See a LogEntry Resource.

data object | string

The data to use as the value for this log entry.

If providing an object, these value types are supported:
- `String`
- `Number`
- `Boolean`
- `Buffer`
- `Object`
- `Array`

Any other types are stringified with `String(value)`.
See:
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.
  }
});

Members

data :object

metadata :object

Properties:
Name Type Description
timestamp Date
insertId number

Methods

toJSON(optionsopt)

Serialize an entry to the format the API expects.

Parameters:
Name Type Attributes Description
options object <optional>

Configuration object.

Properties
Name Type Attributes Description
removeCircular boolean <optional>

Replace circular references in an object with a string value, [Circular].