Class LogSync (9.5.7)

A logSync is a named collection of entries in structured log format. In Cloud Logging, structured logs refer to log entries that use the jsonPayload field to add structure to their payloads. In most GCP environments, like GKE and Cloud Functions, structured logs written to process.stdout are automatically picked up and formatted by logging agents.

Recommended for Serverless environment logging, especially where async log calls made by the Log class can be dropped by the CPU.

[Structured Logging]https://cloud.google.com/logging/docs/structured-logging

Package

@google-cloud/logging!

Constructors

(constructor)(logging, name, transport)

constructor(logging: Logging, name: string, transport?: Writable);

Constructs a new instance of the LogSync class

Parameters
NameDescription
logging Logging
name string
transport Writable

Properties

formattedName_

formattedName_: string;
Property Value
TypeDescription
string

logging

logging: Logging;
Property Value
TypeDescription
Logging

name

name: string;
Property Value
TypeDescription
string

transport

transport: Writable;
Property Value
TypeDescription
Writable

Methods

alert(entry, options)

alert(entry: Entry | Entry[], options?: WriteOptions): void;

Write a log entry with a severity of "ALERT".

This is a simple wrapper around . All arguments are the same as documented there.

Parameters
NameDescription
entry Entry | Entry[]

A log entry, or array of entries, to write.

options WriteOptions

Write options

Returns
TypeDescription
void

critical(entry, options)

critical(entry: Entry | Entry[], options?: WriteOptions): void;

Write a log entry with a severity of "CRITICAL".

This is a simple wrapper around . All arguments are the same as documented there.

Parameters
NameDescription
entry Entry | Entry[]

A log entry, or array of entries, to write.

options WriteOptions

Write options

Returns
TypeDescription
void

debug(entry, options)

debug(entry: Entry | Entry[], options?: WriteOptions): void;

Write a log entry with a severity of "DEBUG".

This is a simple wrapper around . All arguments are the same as documented there.

Parameters
NameDescription
entry Entry | Entry[]

A log entry, or array of entries, to write.

options WriteOptions

Write options

Returns
TypeDescription
void

emergency(entry, options)

emergency(entry: Entry | Entry[], options?: WriteOptions): void;

Write a log entry with a severity of "EMERGENCY".

This is a simple wrapper around . All arguments are the same as documented there.

Parameters
NameDescription
entry Entry | Entry[]

A log entry, or array of entries, to write.

options WriteOptions

Write options

Returns
TypeDescription
void

entry(metadata)

entry(metadata?: LogEntry): Entry;
Parameter
NameDescription
metadata LogEntry
Returns
TypeDescription
Entry

entry(data)

entry(data?: string | {}): Entry;
Parameter
NameDescription
data string | {}
Returns
TypeDescription
Entry

entry(metadata, data)

entry(metadata?: LogEntry, data?: string | {}): Entry;
Parameters
NameDescription
metadata LogEntry
data string | {}
Returns
TypeDescription
Entry

error(entry, options)

error(entry: Entry | Entry[], options?: WriteOptions): void;

Write a log entry with a severity of "ERROR".

This is a simple wrapper around . All arguments are the same as documented there.

Parameters
NameDescription
entry Entry | Entry[]

A log entry, or array of entries, to write.

options WriteOptions

Write options

Returns
TypeDescription
void

info(entry, options)

info(entry: Entry | Entry[], options?: WriteOptions): void;

Write a log entry with a severity of "INFO".

This is a simple wrapper around . All arguments are the same as documented there.

Parameters
NameDescription
entry Entry | Entry[]

A log entry, or array of entries, to write.

options WriteOptions

Write options

Returns
TypeDescription
void

notice(entry, options)

notice(entry: Entry | Entry[], options?: WriteOptions): void;

Write a log entry with a severity of "NOTICE".

This is a simple wrapper around . All arguments are the same as documented there.

Parameters
NameDescription
entry Entry | Entry[]

A log entry, or array of entries, to write.

options WriteOptions

Write options

Returns
TypeDescription
void

warning(entry, options)

warning(entry: Entry | Entry[], options?: WriteOptions): void;

Write a log entry with a severity of "WARNING".

This is a simple wrapper around . All arguments are the same as documented there.

Parameters
NameDescription
entry Entry | Entry[]

A log entry, or array of entries, to write.

options WriteOptions

Write options

Returns
TypeDescription
void

write(entry, opts)

write(entry: Entry | Entry[], opts?: WriteOptions): void;

Write log entries to a custom transport (default: process.stdout).

Parameters
NameDescription
entry Entry | Entry[]

A log entry, or array of entries, to write.

opts WriteOptions
Returns
TypeDescription
void