Skip to content

Commit f0e1fd4

Browse files
authored
misc laravel improvements (GoogleCloudPlatform#838)
1 parent 6365ab2 commit f0e1fd4

File tree

4 files changed

+24
-23
lines changed

4 files changed

+24
-23
lines changed

appengine/php72/laravel-framework/bootstrap/app.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
App\Exceptions\Handler::class
4242
);
4343

44-
# [START google-app-engine-deployment]
44+
# [START] Set the storage path to the environment variable APP_STORAGE
4545
/*
4646
|--------------------------------------------------------------------------
4747
| Set Storage Path
@@ -54,7 +54,7 @@
5454
*/
5555

5656
$app->useStoragePath(env('APP_STORAGE', base_path() . '/storage'));
57-
# [END google-app-engine-deployment]
57+
# [END]
5858

5959
/*
6060
|--------------------------------------------------------------------------

appengine/php72/laravel-framework/config/logging.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@
3030
*/
3131

3232
'channels' => [
33+
34+
# [START] Add Stackdriver Logging and Error Reporting to your Laraval application
35+
'stackdriver' => [
36+
'driver' => 'custom',
37+
'via' => App\Logging\CreateStackdriverLogger::class,
38+
'level' => 'debug',
39+
],
40+
# [END]
41+
3342
'stack' => [
3443
'driver' => 'stack',
3544
'channels' => ['single'],
@@ -66,14 +75,6 @@
6675
'level' => 'debug',
6776
],
6877

69-
# [START] Add Stackdriver Logging and Error Reporting to your Laraval application
70-
'stackdriver' => [
71-
'driver' => 'custom',
72-
'via' => App\Logging\CreateStackdriverLogger::class,
73-
'level' => 'debug',
74-
],
75-
# [END]
76-
7778
],
7879

7980
];

appengine/php72/laravel-framework/routes/web.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
return view('welcome');
1616
});
1717

18-
Route::get('/log/{token}', function ($token) {
19-
Log::info("Hello my log, token: $token");
18+
Route::get('/log/{message}', function ($message) {
19+
Log::info("Hello my log, message: $message");
2020
return view('welcome');
2121
});
2222

23-
Route::get('/exception/{token}', function ($token) {
24-
throw new Exception("Intentional exception, token: $token");
23+
Route::get('/exception/{message}', function ($message) {
24+
throw new Exception("Intentional exception, message: $message");
2525
});

appengine/php72/laravel-framework/test/DeployStackdriverTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,16 @@ public function testLogging()
6565
'projectId' => self::getProjectId()
6666
]);
6767

68-
$token = uniqid();
68+
$message = uniqid();
6969
// The routes are defined in routes/web.php
70-
$resp = $this->client->request('GET', "/log/$token", [
70+
$resp = $this->client->request('GET', "/log/$message", [
7171
'http_errors' => false
7272
]);
7373
$this->assertEquals('200', $resp->getStatusCode(), 'log page status code');
7474

7575
// 'app' is the default logname of our Stackdriver Logging integration.
7676
$logger = $logging->logger('app');
77-
$this->runEventuallyConsistentTest(function () use ($logger, $token) {
77+
$this->runEventuallyConsistentTest(function () use ($logger, $message) {
7878
$logs = $logger->entries([
7979
'pageSize' => 100,
8080
'orderBy' => 'timestamp desc',
@@ -83,11 +83,11 @@ public function testLogging()
8383
$found = false;
8484
foreach ($logs as $log) {
8585
$info = $log->info();
86-
if (false !== strpos($info['jsonPayload']['message'], "token: $token")) {
86+
if (false !== strpos($info['jsonPayload']['message'], "message: $message")) {
8787
$found = true;
8888
}
8989
}
90-
$this->assertTrue($found, "The log entry $token was not found");
90+
$this->assertTrue($found, "The log entry $message was not found");
9191
}, $eventuallyConsistentRetryCount = 5);
9292
}
9393

@@ -97,16 +97,16 @@ public function testErrorReporting()
9797
'projectId' => self::getProjectId()
9898
]);
9999

100-
$token = uniqid();
100+
$message = uniqid();
101101
// The routes are defined in routes/web.php
102-
$resp = $this->client->request('GET', "/exception/$token", [
102+
$resp = $this->client->request('GET', "/exception/$message", [
103103
'http_errors' => false
104104
]);
105105
$this->assertEquals('500', $resp->getStatusCode(), 'exception page status code');
106106

107107
// 'app-error' is the default logname of our Stackdriver Error Reporting integration.
108108
$logger = $logging->logger('app-error');
109-
$this->runEventuallyConsistentTest(function () use ($logger, $token) {
109+
$this->runEventuallyConsistentTest(function () use ($logger, $message) {
110110
$logs = $logger->entries([
111111
'pageSize' => 100,
112112
'orderBy' => 'timestamp desc',
@@ -115,7 +115,7 @@ public function testErrorReporting()
115115
$found = false;
116116
foreach ($logs as $log) {
117117
$info = $log->info();
118-
if (false !== strpos($info['jsonPayload']['message'], "token: $token")) {
118+
if (false !== strpos($info['jsonPayload']['message'], "message: $message")) {
119119
$found = true;
120120
}
121121
}

0 commit comments

Comments
 (0)