Skip to content

Commit a02e17b

Browse files
committed
Log Cloud runtime diagnostics
1 parent 3ad7c7a commit a02e17b

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

src/craft-cloud-init.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,29 @@
33
declare(strict_types=1);
44

55
error_log('[craft-cloud] Composer autoload file loaded.');
6+
7+
$diagnosticKeys = [
8+
'AWS_LAMBDA_RUNTIME_API',
9+
'CRAFT_CLOUD',
10+
'CRAFT_CLOUD_PROJECT_ID',
11+
'CRAFT_CLOUD_ENVIRONMENT_ID',
12+
'LOG_CHANNEL',
13+
'LOG_STACK',
14+
'LOG_STDERR_FORMATTER',
15+
];
16+
17+
$diagnostics = [];
18+
19+
foreach ($diagnosticKeys as $key) {
20+
$serverValue = $_SERVER[$key] ?? null;
21+
$envValue = $_ENV[$key] ?? null;
22+
$getenvValue = getenv($key);
23+
24+
$diagnostics[$key] = [
25+
'server' => $serverValue === null ? null : (string) $serverValue,
26+
'env' => $envValue === null ? null : (string) $envValue,
27+
'getenv' => $getenvValue === false ? null : $getenvValue,
28+
];
29+
}
30+
31+
error_log('[craft-cloud] Runtime diagnostics: ' . json_encode($diagnostics));

0 commit comments

Comments
 (0)