Class Entry (11.2.0)

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

Package

@google-cloud/logging

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. 
  
 } 
 }); 
 

Constructors

(constructor)(metadata, data)

  constructor 
 ( 
 metadata 
 ?: 
  
 LogEntry 
 , 
  
 data 
 ?: 
  
 Data 
 ); 
 

Constructs a new instance of the Entry class

Parameters
Name
Description
metadata
LogEntry
data
Data

Properties

data

  data 
 : 
  
 Data 
 ; 
 
  metadata 
 : 
  
 LogEntry 
 ; 
 

Methods

fromApiResponse_(entry)

  static 
  
 fromApiResponse_ 
 ( 
 entry 
 : 
  
 google 
 . 
 logging 
 . 
 v2 
 . 
 LogEntry 
 ) 
 : 
  
 Entry 
 ; 
 

Create an Entry object from an API response, such as entries:list .

Parameter
Name
Description
entry
LogEntry

An API representation of an entry. See a LogEntry .

Returns
Type
Description

{Entry}

toJSON(options, projectId)

  toJSON 
 ( 
 options 
 ?: 
  
 ToJsonOptions 
 , 
  
 projectId 
 ?: 
  
 string 
 ) 
 : 
  
 EntryJson 
 ; 
 

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

Parameters
Name
Description
options
ToJsonOptions

Configuration object.

projectId
string

GCP Project ID.

Returns
Type
Description
EntryJson

toStructuredJSON(projectId, useMessageField)

  toStructuredJSON 
 ( 
 projectId 
 ?: 
  
 string 
 , 
  
 useMessageField 
 ?: 
  
 boolean 
 ) 
 : 
  
 StructuredJson 
 ; 
 

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

Parameters
Name
Description
projectId
string
useMessageField
boolean
Returns
Type
Description
StructuredJson
Design a Mobile Site
View Site in Mobile | Classic
Share by: