Skip to content

Commit 3d11706

Browse files
author
Ace Nassri
authored
chore(functions): add more logging methods (GoogleCloudPlatform#1220)
1 parent c655f10 commit 3d11706

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

functions/log_helloworld/index.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,17 @@ function helloLogging(ServerRequestInterface $request): string
3737
// This doesn't log anything
3838
error_log('error_log does not log in Cloud Functions!');
3939

40+
// This will log an error message and immediately terminate the function execution
41+
// trigger_error('fatal errors are logged!');
42+
4043
// For HTTP functions, this is added to the HTTP response
4144
// For CloudEvent functions, this does nothing
4245
var_dump('var_dump goes to HTTP response for HTTP functions');
46+
47+
// You can also dump variables using var_export() and forward
48+
// the resulting string to Cloud Logging via an fwrite() call.
49+
$entry = var_export('var_export output can be captured.', true);
50+
fwrite($log, $entry);
4351

4452
// Functions must return a String or PSR-7 Response object
4553
return '';

0 commit comments

Comments
 (0)