Entry

Entry

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

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

See LogEntry JSON representation

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)`.
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

metadata

Properties:
Name Type Description
timestamp Date
insertId number

Methods

isObject(value)

Determines whether value is a JavaScript object.

Parameters:
Name Type Description
value

The value to be checked

Returns:
Type Description

true if value is a JavaScript object, false otherwise

toJSON(optionsopt, projectIdopt)

Serialize an entry to the format the API expects. Read more: https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry

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].

projectId string <optional>

GCP Project ID.

toStructuredJSON()

Serialize an entry to a standard format for any transports, e.g. agents. Read more: https://cloud.google.com/logging/docs/structured-logging