PHP Класс Google\Cloud\Logging\Logger

Example: use Google\Cloud\ServiceBuilder; $cloud = new ServiceBuilder(); $logging = $cloud->logging(); $logger = $logging->logger('my-log');
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$connection Represents a connection to Stackdriver Logging.

Открытые методы

Метод Описание
__construct ( Google\Cloud\Logging\Connection\ConnectionInterface $connection, string $name, string $projectId, array $resource = null, array $labels = null )
delete ( array $options = [] ) Deletes this log and all its log entries. The log will reappear if it receives new entries.
entries ( array $options = [] ) : Generator Fetches entries scoped to the selected log.
entry ( array | string $data, array $options = [] ) : Entry Creates an entry which which can be written to a log. In order to write the entry to the log please use {@see Google\Cloud\Logging\Logger::write()} or {@see Google\Cloud\Logging\Logger::writeBatch()}.
getLogLevelMap ( ) Returns the log level map.
write ( array | string | Entry $entry, array $options = [] ) Write a single entry to the log.
writeBatch ( array $entries, array $options = [] ) Write a set of entries to the log.

Описание методов

__construct() публичный Метод

public __construct ( Google\Cloud\Logging\Connection\ConnectionInterface $connection, string $name, string $projectId, array $resource = null, array $labels = null )
$connection Google\Cloud\Logging\Connection\ConnectionInterface Represents a connection to Stackdriver Logging.
$name string The name of the log to write entries to.
$projectId string The project's ID.
$resource array [optional] The [monitored resource](https://cloud.google.com/logging/docs/api/reference/rest/Shared.Types/MonitoredResource) 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() публичный Метод

Example: $logger->delete();
См. также: https://cloud.google.com/logging/docs/api/reference/rest/v2/projects.logs/delete projects.logs delete API documentation.
public delete ( array $options = [] )
$options array [optional] Configuration Options.

entries() публичный Метод

Please note that a default filter specifying the logName will be applied for you. Example: $entries = $logger->entries(); foreach ($entries as $entry) { echo $entry->info()['textPayload'] . PHP_EOL; } Use an advanced logs filter to fetch only entries with a specific payload. $entries = $logger->entries([ 'filter' => 'textPayload = "hello world"' ]); foreach ($entries as $entry) { echo $entry->info()['textPayload'] . PHP_EOL; }
См. также: https://cloud.google.com/logging/docs/api/reference/rest/v2/entries/list Entries list API documentation.
public entries ( array $options = [] ) : Generator
$options array [optional] { Configuration options. @type string $filter An [advanced logs filter](https://cloud.google.com/logging/docs/view/advanced_filters). @type string $orderBy How the results should be sorted. Presently, the only permitted values are `timestamp asc` and `timestamp desc`. **Defaults to** `"timestamp asc"`. @type int $pageSize The maximum number of results to return per request. }
Результат Generator

entry() публичный Метод

Example: Create an entry with a key/value set of data $entry = $logger->entry(['user' => 'calvin']); Create an entry with a string $entry = $logger->entry('my message'); Create an entry with a severity of EMERGENCY and specifying a resource. $entry = $logger->entry('my message', [ 'severity' => Logger::EMERGENCY, 'resource' => [ 'type' => 'gcs_bucket', 'labels' => [ 'bucket_name' => 'my-bucket' ] ] ]);
См. также: https://cloud.google.com/logging/docs/api/reference/rest/Shared.Types/LogEntry LogEntry resource documentation.
public entry ( array | string $data, array $options = [] ) : Entry
$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 [optional] { Configuration options. @type array $resource The [monitored resource](https://cloud.google.com/logging/docs/api/reference/rest/Shared.Types/MonitoredResource) to associate this log entry with. **Defaults to** type global. @type array $httpRequest Information about the HTTP request associated with this log entry, if applicable. Please see [the API docs](https://cloud.google.com/logging/docs/api/reference/rest/Shared.Types/LogEntry#httprequest) for more information. @type array $labels A set of user-defined (key, value) data that provides additional information about the log entry. @type array $operation Additional information about a potentially long-running operation with which a log entry is associated. Please see [the API docs](https://cloud.google.com/logging/docs/api/reference/rest/Shared.Types/LogEntry#logentryoperation) for more information. @type string|int $severity The severity of the log entry. **Defaults to** `"DEFAULT"`. }
Результат Entry

getLogLevelMap() публичный статический Метод

Returns the log level map.
public static getLogLevelMap ( )

write() публичный Метод

Example: Writing a simple log entry. $logger->write('a log entry'); Writing a simple entry with a key/value set of data and a severity of EMERGENCY. $logger->write(['user' => 'calvin'], [ 'severity' => Logger::EMERGENCY ]); Using the entry factory method to write a log entry. $entry = $logger->entry('a log entry'); $logger->write($entry);
См. также: https://cloud.google.com/logging/docs/api/reference/rest/v2/entries/write Entries write API documentation.
public write ( array | string | Entry $entry, array $options = [] )
$entry array | string | Entry The entry to write to the log.
$options array [optional] Please see {@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() публичный Метод

Example: $entries = []; $entries[] = $logger->entry('my message'); $entries[] = $logger->entry('my second message'); $logger->writeBatch($entries);
См. также: https://cloud.google.com/logging/docs/api/reference/rest/v2/entries/write Entries write API documentation.
public writeBatch ( array $entries, array $options = [] )
$entries array Entries to write to the log.
$options array [optional] Configuration Options.

Описание свойств

$connection защищенное свойство

Represents a connection to Stackdriver Logging.
protected $connection