Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions appengine/flexible/logging/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
* limitations under the License.
*/

# [START logging_creating_psr3_logger_import]
# [START creating_psr3_logger_import]
use Google\Cloud\Logging\LoggingClient;
# [END creating_psr3_logger_import]
# [END logging_creating_psr3_logger_import]
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Message\ResponseInterface as Response;
use Slim\Factory\AppFactory;
Expand Down Expand Up @@ -58,12 +60,14 @@
$app->post('/log', function (Request $request, Response $response) use ($projectId) {
parse_str((string) $request->getBody(), $postData);
# [START gae_flex_configure_logging]
# [START logging_creating_psr3_logger]
# [START creating_psr3_logger]
$logging = new LoggingClient([
'projectId' => $projectId
]);
$logger = $logging->psrLogger('app');
# [END creating_psr3_logger]
# [END logging_creating_psr3_logger]
$logger->notice($postData['text'] ?? '');
# [END gae_flex_configure_logging]
return $response
Expand All @@ -73,13 +77,17 @@

$app->get('/async_log', function (Request $request, Response $response) use ($projectId) {
$token = $request->getUri()->getQuery('token');
# [START logging_enabling_psr3_batch]
# [START enabling_batch]
$logger = LoggingClient::psrBatchLogger('app');
# [END enabling_batch]
# [END logging_enabling_psr3_batch]
# [START logging_using_psr3_logger]
# [START using_the_logger]
$logger->info('Hello World');
$logger->error('Oh no');
# [END using_the_logger]
# [END logging_using_psr3_logger]
$logger->info("Token: $token");
$response->getBody()->write('Sent some logs');
return $response;
Expand Down