Skip to content

Commit 4692e92

Browse files
chore(logging): adding product prefix to region tags to enable tracking (GoogleCloudPlatform#1728)
1 parent 4c5ca5f commit 4692e92

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

appengine/flexible/logging/app.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@
1515
* limitations under the License.
1616
*/
1717

18+
# [START logging_creating_psr3_logger_import]
1819
# [START creating_psr3_logger_import]
1920
use Google\Cloud\Logging\LoggingClient;
2021
# [END creating_psr3_logger_import]
22+
# [END logging_creating_psr3_logger_import]
2123
use Psr\Http\Message\ServerRequestInterface as Request;
2224
use Psr\Http\Message\ResponseInterface as Response;
2325
use Slim\Factory\AppFactory;
@@ -58,12 +60,14 @@
5860
$app->post('/log', function (Request $request, Response $response) use ($projectId) {
5961
parse_str((string) $request->getBody(), $postData);
6062
# [START gae_flex_configure_logging]
63+
# [START logging_creating_psr3_logger]
6164
# [START creating_psr3_logger]
6265
$logging = new LoggingClient([
6366
'projectId' => $projectId
6467
]);
6568
$logger = $logging->psrLogger('app');
6669
# [END creating_psr3_logger]
70+
# [END logging_creating_psr3_logger]
6771
$logger->notice($postData['text'] ?? '');
6872
# [END gae_flex_configure_logging]
6973
return $response
@@ -73,13 +77,17 @@
7377

7478
$app->get('/async_log', function (Request $request, Response $response) use ($projectId) {
7579
$token = $request->getUri()->getQuery('token');
80+
# [START logging_enabling_psr3_batch]
7681
# [START enabling_batch]
7782
$logger = LoggingClient::psrBatchLogger('app');
7883
# [END enabling_batch]
84+
# [END logging_enabling_psr3_batch]
85+
# [START logging_using_psr3_logger]
7986
# [START using_the_logger]
8087
$logger->info('Hello World');
8188
$logger->error('Oh no');
8289
# [END using_the_logger]
90+
# [END logging_using_psr3_logger]
8391
$logger->info("Token: $token");
8492
$response->getBody()->write('Sent some logs');
8593
return $response;

0 commit comments

Comments
 (0)