PHP Class Google\Cloud\Logging\PsrLogger

Example: use Google\Cloud\ServiceBuilder; $cloud = new ServiceBuilder(); $logging = $cloud->logging(); $psrLogger = $logging->psrLogger('my-log', [ 'type' => 'gcs_bucket', 'labels' => [ 'bucket_name' => 'my-bucket' ] ]);
Inheritance: implements Psr\Log\LoggerInterface
Datei anzeigen Open project: GoogleCloudPlatform/gcloud-php

Protected Properties

Property Type Description
$logger The logger used to write entries.

Public Methods

Method Description
__construct ( Logger $logger, string $messageKey = 'message' )
alert ( string $message, array $context = [] ) Log an alert entry.
critical ( string $message, array $context = [] ) Log a critical entry.
debug ( string $message, array $context = [] ) Log a debug entry.
emergency ( string $message, array $context = [] ) Log an emergency entry.
error ( string $message, array $context = [] ) Log an error entry.
info ( string $message, array $context = [] ) Log an info entry.
log ( string | integer $level, string $message, array $context = [] ) Write a log entry.
notice ( string $message, array $context = [] ) Log a notice entry.
warning ( string $message, array $context = [] ) Log a warning entry.

Private Methods

Method Description
validateLogLevel ( string | integer $level ) : boolean Validates whether or not the provided log level exists.

Method Details

__construct() public method

public __construct ( Logger $logger, string $messageKey = 'message' )
$logger Logger The logger used to write entries.
$messageKey string The key in the `jsonPayload` used to contain the logged message. **Defaults to** `message`.

alert() public method

Example: $psrLogger->alert('alert message');
public alert ( string $message, array $context = [] )
$message string The message to log.
$context array [optional] Please see {@see \Google\Cloud\Logging\PsrLogger::log()} for the available options.

critical() public method

Example: $psrLogger->critical('critical message');
public critical ( string $message, array $context = [] )
$message string The message to log.
$context array [optional] Please see {@see \Google\Cloud\Logging\PsrLogger::log()} for the available options.

debug() public method

Example: $psrLogger->debug('debug message');
public debug ( string $message, array $context = [] )
$message string The message to log.
$context array [optional] Please see {@see \Google\Cloud\Logging\PsrLogger::log()} for the available options.

emergency() public method

Example: $psrLogger->emergency('emergency message');
public emergency ( string $message, array $context = [] )
$message string The message to log.
$context array [optional] Please see {@see \Google\Cloud\Logging\PsrLogger::log()} for the available options.

error() public method

Example: $psrLogger->error('error message');
public error ( string $message, array $context = [] )
$message string The message to log.
$context array [optional] Please see {@see \Google\Cloud\Logging\PsrLogger::log()} for the available options.

info() public method

Example: $psrLogger->info('info message');
public info ( string $message, array $context = [] )
$message string The message to log.
$context array [optional] Please see {@see \Google\Cloud\Logging\PsrLogger::log()} for the available options.

log() public method

Example: use Google\Cloud\Logging\Logger; $psrLogger->log(Logger::ALERT, 'alert message'); Write a log entry using the context array with placeholders. use Google\Cloud\Logging\Logger; $psrLogger->log(Logger::ALERT, 'alert: {message}', [ 'message' => 'my alert message' ]); Log information regarding an HTTP request use Google\Cloud\Logging\Logger; $psrLogger->log(Logger::ALERT, 'alert message', [ 'stackdriverOptions' => [ 'httpRequest' => [ 'requestMethod' => 'GET' ] ] ]);
public log ( string | integer $level, string $message, array $context = [] )
$level string | integer The severity of the log entry.
$message string The message to log.
$context array { Context is an associative array which can include placeholders to be used in the `$message`. Placeholders must be delimited with a single opening brace `{` and a single closing brace `}`. The context will be added as additional information on the `jsonPayload`. Please note that the key `stackdriverOptions` is reserved for logging Google Stackdriver specific data. @type array $stackdriverOptions['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 $stackdriverOptions['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 $stackdriverOptions['labels'] A set of user-defined (key, value) data that provides additional information about the log entry. @type array $stackdriverOptions['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. }

notice() public method

Example: $psrLogger->notice('notice message');
public notice ( string $message, array $context = [] )
$message string The message to log.
$context array [optional] Please see {@see \Google\Cloud\Logging\PsrLogger::log()} for the available options.

warning() public method

Example: $psrLogger->warning('warning message');
public warning ( string $message, array $context = [] )
$message string The message to log.
$context array [optional] Please see {@see \Google\Cloud\Logging\PsrLogger::log()} for the available options.

Property Details

$logger protected_oe property

The logger used to write entries.
protected $logger