Properties

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.

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

Any other types are stringified with String(value).

See also

LogEntry JSON representation

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 options have the following properties:

Name Type Optional Description

removeCircular

boolean

Yes

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