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
Name | Description |
logging |
Logging
|
name |
string
|
transport |
Writable
|
Properties
formattedName_
formattedName_: string;
Type | Description |
string |
logging
logging: Logging;
Type | Description |
Logging |
name
name: string;
Type | Description |
string |
transport
transport: Writable;
Type | Description |
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.
Name | Description |
entry |
Entry | Entry[]
A log entry, or array of entries, to write. |
options |
WriteOptions
Write options |
Type | Description |
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.
Name | Description |
entry |
Entry | Entry[]
A log entry, or array of entries, to write. |
options |
WriteOptions
Write options |
Type | Description |
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.
Name | Description |
entry |
Entry | Entry[]
A log entry, or array of entries, to write. |
options |
WriteOptions
Write options |
Type | Description |
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.
Name | Description |
entry |
Entry | Entry[]
A log entry, or array of entries, to write. |
options |
WriteOptions
Write options |
Type | Description |
void |
entry(metadata)
entry(metadata?: LogEntry): Entry;
Name | Description |
metadata |
LogEntry
|
Type | Description |
Entry |
entry(data)
entry(data?: string | {}): Entry;
Name | Description |
data |
string | {}
|
Type | Description |
Entry |
entry(metadata, data)
entry(metadata?: LogEntry, data?: string | {}): Entry;
Name | Description |
metadata |
LogEntry
|
data |
string | {}
|
Type | Description |
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.
Name | Description |
entry |
Entry | Entry[]
A log entry, or array of entries, to write. |
options |
WriteOptions
Write options |
Type | Description |
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.
Name | Description |
entry |
Entry | Entry[]
A log entry, or array of entries, to write. |
options |
WriteOptions
Write options |
Type | Description |
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.
Name | Description |
entry |
Entry | Entry[]
A log entry, or array of entries, to write. |
options |
WriteOptions
Write options |
Type | Description |
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.
Name | Description |
entry |
Entry | Entry[]
A log entry, or array of entries, to write. |
options |
WriteOptions
Write options |
Type | Description |
void |
write(entry, opts)
write(entry: Entry | Entry[], opts?: WriteOptions): void;
Write log entries to a custom transport (default: process.stdout).
Name | Description |
entry |
Entry | Entry[]
A log entry, or array of entries, to write. |
opts |
WriteOptions
|
Type | Description |
void |