Stackdriver Logging Client - Class Logger (1.29.0)

Reference documentation and code samples for the Stackdriver Logging Client class Logger.

A logger used to write entries to Google Stackdriver Logging.

Example:

use Google\Cloud\Logging\LoggingClient;

$logging = new LoggingClient();

$logger = $logging->logger('my-log');

Namespace

Google \ Cloud \ Logging

Methods

__construct

Parameters
NameDescription
connection Google\Cloud\Logging\Connection\ConnectionInterface

Represents a connection to Stackdriver Logging. This object is created by LoggingClient, and should not be instantiated outside of this client.

name string

The name of the log to write entries to.

projectId string

The project's ID.

resource array

[optional] The monitored resource to associate log entries with. Defaults to type global.

labels array

[optional] A set of user-defined (key, value) data that provides additional information about the log entries.

delete

Parameter
NameDescription
options array

[optional] Configuration Options.

entries

Parameters
NameDescription
options array

Configuration options.

↳ filter string

An advanced logs filter.

↳ orderBy string

How the results should be sorted. Presently, the only permitted values are timestamp asc and timestamp desc. Defaults to "timestamp asc".

↳ pageSize int

The maximum number of results to return per request.

↳ resultLimit int

Limit the number of results returned in total. Defaults to 0 (return all results).

↳ pageToken string

A previously-returned page token used to resume the loading of results from a specific point.

Returns
TypeDescription
Google\Cloud\Core\Iterator\ItemIterator<\google\cloud\logging\entry>

entry

Parameters
NameDescription
data array|string

The data to log. When providing a string the data will be stored as a textPayload type. When providing an array the data will be stored as a jsonPayload type.

options array

Configuration options.

↳ resource array

The monitored resource to associate this log entry with. Defaults to type global.

↳ timestamp DateTimeInterface|Timestamp|string|null

The timestamp associated with this entry. If providing a string it must be in RFC3339 UTC "Zulu" format. Example: "2014-10-02T15:01:23.045123456Z". If explicitly set to null the timestamp will be generated by the server at the moment the entry is received (with nanosecond precision). Defaults to the current time, generated by the client with microsecond precision.

↳ severity string|int

The severity of the log entry. Defaults to "DEFAULT".

↳ insertId string

A unique identifier for the log entry.

↳ httpRequest array

Information about the HTTP request associated with this log entry, if applicable. Please see the API docs for more information.

↳ labels array

A set of user-defined (key, value) data that provides additional information about the log entry.

↳ operation array

Additional information about a potentially long-running operation with which a log entry is associated. Please see the API docs for more information.

↳ spanId string

Optional. The span ID within the trace associated with the log entry. For Trace spans, this is the same format that the Trace API v2 uses: a 16-character hexadecimal encoding of an 8-byte array, such as 000000000000004a.

↳ trace string

Optional. Resource name of the trace associated with the log entry, if any. If it contains a relative resource name, the name is assumed to be relative to //tracing.googleapis.com. Example: projects/my-projectid/traces/06796866738c859f2f19b7cfb3214824.

↳ traceSampled bool

True means that the trace resource name in the trace field was sampled for storage in a trace backend. False means that the trace was not sampled for storage when this log entry was written, or the sampling decision was unknown at the time. A non-sampled trace value is still useful as a request correlation identifier. The default is False.

↳ sourceLocation array

Source code location information associated with the log entry, if any. Please see the API docs for more information.

Returns
TypeDescription
Google\Cloud\Logging\Entry

write

Parameters
NameDescription
entry array|string|Google\Cloud\Logging\Entry

The entry to write to the log.

options array

[optional] Please see Google\Cloud\Logging\Logger::entry() to see the options that can be applied to a log entry. Please note that if the provided entry is of type Entry these options will overwrite those that may already be set on the instance.

writeBatch

Parameters
NameDescription
entries array<Google\Cloud\Logging\Entry>

Entries to write to the log.

options array

[optional] Configuration Options.

name

Returns the logger's name.

Returns
TypeDescription
string

static::getLogLevelMap

Returns the log level map.

Returns
TypeDescription
array

Constants

EMERGENCY

Value: 800

ALERT

Value: 700

CRITICAL

Value: 600

ERROR

Value: 500

WARNING

Value: 400

NOTICE

Value: 300

INFO

Value: 200

DEBUG

Value: 100

DEFAULT_LEVEL

Value: 0