Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/inquid/yii2-google-debugger
Use Google Cloud Logger into your Yii projects
https://github.com/inquid/yii2-google-debugger
google-cloud yii2 yii2-extension
Last synced: 23 days ago
JSON representation
Use Google Cloud Logger into your Yii projects
- Host: GitHub
- URL: https://github.com/inquid/yii2-google-debugger
- Owner: inquid
- Created: 2018-02-20T15:16:28.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2021-06-04T01:42:04.000Z (over 3 years ago)
- Last Synced: 2024-12-13T22:29:08.609Z (28 days ago)
- Topics: google-cloud, yii2, yii2-extension
- Language: PHP
- Size: 10.7 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&[email protected]&item_name=Yii2+extensions+support&item_number=22+Campaign&amount=5%2e00¤cy_code=USD)
Google Debugger for Yii
=======================
Use Google Cloud Logger into your Yii projectsInstallation
------------The preferred way to install this extension is through [composer](http://getcomposer.org/download/).
Either run
```
php composer.phar require --prefer-dist inquid/yii2-google-debugger "*"
```or add
```
"inquid/yii2-google-debugger": "*"
```to the require section of your `composer.json` file.
Usage
-----Once the extension is installed, simply generate a service account with Cloud Debugger Agent permissions and configure your target as the following:
```php
'log' => [
'traceLevel' => YII_DEBUG ? 3 : 0,
'targets' => [
'googleCloud' => [
'class' => 'inquid\google_debugger\GoogleCloudLogger',
'categories' => ['cat1','cat2'], //Your categories to log
'levels' => ['info', 'trace', 'warning', 'error'],
'except' => ['yii\web\HttpException:*', 'yii\i18n\I18N\*'],
'prefix' => function () {
$url = !Yii::$app->request->isConsoleRequest ? Yii::$app->request->getUrl() : null;
return sprintf('[%s][%s]', Yii::$app->id, $url);
},
'projectId' => 'project-id',
'loggerInstance' => 'instance-log',
'clientSecretPath' => '../google_credentials.json' //path to your service account credentials
]
],
],
```And thats it! log as you may log using Yii
```php
Yii::debug('start calculating average revenue',GoogleCloudLogger::CATEGORY);
Yii::warning('Warning');
Yii::info('Info');
Yii::error('Error');
```And check them in https://console.cloud.google.com/logs/viewer?project=your_project_id
SUPPORT
-----
[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&[email protected]&item_name=Yii2+extensions+support&item_number=22+Campaign&amount=5%2e00¤cy_code=USD)