Constructor

Entry

new Entry(metadata, data)

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

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.

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

Example

var Logging = require('@google-cloud/logging');
var logging = new Logging();
var syslog = logging.log('syslog');

var metadata = {
  resource: {
    type: 'gce_instance',
    labels: {
      zone: 'global',
      instance_id: '3'
    }
  }
};

var entry = syslog.entry(metadata, {
  delegate: 'my_username'
});

syslog.alert(entry, function(err, apiResponse) {
  if (!err) {
    // Log entry inserted successfully.
  }
});

//-
// You will also receive `Entry` objects when using
// Logging#getEntries() and Log#getEntries().
//-
logging.getEntries(function(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 options have the following properties:

Parameter

removeCircular

Optional

boolean

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