File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed
error_reporting/quickstart Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change 77// Imports the Google Cloud client library
88use Google \Cloud \Logging \LoggingClient ;
99
10- // Your Google Cloud Platform project ID
11- $ projectId = 'YOUR_PROJECT_ID ' ;
10+ // These variables are set by the App Engine environment. To test locally,
11+ // ensure these are set or manually change their values.
12+ $ projectId = getenv ('GCLOUD_PROJECT ' ) ?: 'YOUR_PROJECT_ID ' ;
13+ $ service = getenv ('GAE_SERVICE ' ) ?: 'error_reporting_quickstart ' ;
14+ $ version = getenv ('GAE_VERSION ' ) ?: '1.0-dev ' ;
1215
1316// Instantiates a client
1417$ logging = new LoggingClient ([
2124// Selects the log to write to
2225$ logger = $ logging ->logger ($ logName );
2326
24- $ handlerFunction = function (Exception $ e ) use ($ logger ) {
27+ $ handlerFunction = function (Exception $ e ) use ($ logger, $ service , $ version ) {
2528 // Creates the log entry with the exception trace
2629 $ entry = $ logger ->entry ([
2730 'message ' => sprintf ('PHP Warning: %s ' , $ e ),
2831 'serviceContext ' => [
29- 'service ' => ' error_reporting_quickstart ' ,
30- 'version ' => ' 1.0-dev ' ,
32+ 'service ' => $ service ,
33+ 'version ' => $ version ,
3134 ]
3235 ]);
3336 // Writes the log entry
You can’t perform that action at this time.
0 commit comments