Constructor
new LogSync(logging, name, transportopt)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
logging |
Logging |
Logging instance. |
|
name |
string |
Name of the logSync. |
|
transport |
Writable |
<optional> |
transport A custom writable transport stream. Default: process.stdout. |
Methods
alert(entry, optionsopt, nullable)
Write a log entry with a severity of "ALERT".
This is a simple wrapper around LogSync#write. All arguments are the same as documented there.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
entry |
Entry | Array.<Entry> |
A log entry, or array of entries, to write. |
|
options |
WriteOptions |
<optional> <nullable> |
Write options |
Example
```
const {Logging} = require('@google-cloud/logging');
const logging = new Logging();
const log = logging.logSync('my-log');
const entry = log.entry('gce_instance', {
instance: 'my_instance'
});
log.alert(entry);
```
critical(entry, optionsopt, nullable)
Write a log entry with a severity of "CRITICAL".
This is a simple wrapper around LogSync#write. All arguments are the same as documented there.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
entry |
Entry | Array.<Entry> |
A log entry, or array of entries, to write. |
|
options |
WriteOptions |
<optional> <nullable> |
Write options |
Example
```
const {Logging} = require('@google-cloud/logging');
const logging = new Logging();
const log = logging.logSync('my-log');
const entry = log.entry('gce_instance', {
instance: 'my_instance'
});
log.critical(entry);
```
debug(entry, optionsopt, nullable)
Write a log entry with a severity of "DEBUG".
This is a simple wrapper around LogSync#write. All arguments are the same as documented there.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
entry |
Entry | Array.<Entry> |
A log entry, or array of entries, to write. |
|
options |
WriteOptions |
<optional> <nullable> |
Write options |
Example
```
const {Logging} = require('@google-cloud/logging');
const logging = new Logging();
const log = logging.logSync('my-log');
const entry = log.entry('gce_instance', {
instance: 'my_instance'
});
log.debug(entry);
```
emergency(entry, optionsopt, nullable)
Write a log entry with a severity of "EMERGENCY".
This is a simple wrapper around LogSync#write. All arguments are the same as documented there.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
entry |
Entry | Array.<Entry> |
A log entry, or array of entries, to write. |
|
options |
WriteOptions |
<optional> <nullable> |
Write options |
Example
```
const {Logging} = require('@google-cloud/logging');
const logging = new Logging();
const log = logging.logSync('my-log');
const entry = log.entry('gce_instance', {
instance: 'my_instance'
});
log.emergency(entry);
```
error(entry, optionsopt, nullable)
Write a log entry with a severity of "ERROR".
This is a simple wrapper around LogSync#write. All arguments are the same as documented there.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
entry |
Entry | Array.<Entry> |
A log entry, or array of entries, to write. |
|
options |
WriteOptions |
<optional> <nullable> |
Write options |
Example
```
const {Logging} = require('@google-cloud/logging');
const logging = new Logging();
const log = logging.logSync('my-log');
const entry = log.entry('gce_instance', {
instance: 'my_instance'
});
log.error(entry);
```
info(entry, optionsopt, nullable)
Write a log entry with a severity of "INFO".
This is a simple wrapper around LogSync#write. All arguments are the same as documented there.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
entry |
Entry | Array.<Entry> |
A log entry, or array of entries, to write. |
|
options |
WriteOptions |
<optional> <nullable> |
Write options |
Example
```
const {Logging} = require('@google-cloud/logging');
const logging = new Logging();
const log = logging.logSync('my-log');
const entry = log.entry('gce_instance', {
instance: 'my_instance'
});
log.info(entry);
```
notice(entry, optionsopt, nullable)
Write a log entry with a severity of "NOTICE".
This is a simple wrapper around LogSync#write. All arguments are the same as documented there.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
entry |
Entry | Array.<Entry> |
A log entry, or array of entries, to write. |
|
options |
WriteOptions |
<optional> <nullable> |
Write options |
Example
```
const {Logging} = require('@google-cloud/logging');
const logging = new Logging();
const log = logging.logSync('my-log');
const entry = log.entry('gce_instance', {
instance: 'my_instance'
});
log.notice(entry);
```
warning(entry, optionsopt, nullable)
Write a log entry with a severity of "WARNING".
This is a simple wrapper around LogSync#write. All arguments are the same as documented there.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
entry |
Entry | Array.<Entry> |
A log entry, or array of entries, to write. |
|
options |
WriteOptions |
<optional> <nullable> |
Write options |
Example
```
const {Logging} = require('@google-cloud/logging');
const logging = new Logging();
const log = logging.logSync('my-log');
const entry = log.entry('gce_instance', {
instance: 'my_instance'
});
log.warning(entry);
```
write(entry, optionsopt, nullable)
Write log entries to a custom transport (default: process.stdout).
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
entry |
Entry | Array.<Entry> |
A log entry, or array of entries, to write. |
|
options |
WriteOptions |
<optional> <nullable> |
Write options |
Example
```
const entry = log.entry('gce_instance', {
instance: 'my_instance'
});
log.write(entry);
//-
// You may also pass multiple log entries to write.
//-
const secondEntry = log.entry('compute.googleapis.com', {
user: 'my_username'
});
log.write([entry, secondEntry]);
//-
// To save some steps, you can also pass in plain values as your entries.
// Note, however, that you must provide a configuration object to specify
// the resource.
//-
const entries = [
{
user: 'my_username'
},
{
home: process.env.HOME
}
];
const options = {
resource: 'compute.googleapis.com'
};
log.write(entries, options);
log.write(entries);
});
```