Skip to content

Commit 650b5e3

Browse files
authored
fix(Logging): format timestamp and severity for API (#9078)
1 parent 7df87f1 commit 650b5e3

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

Logging/src/Connection/Gapic.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,17 @@ public function __construct(private array $config = [])
7676
], [], [
7777
'json_payload' => function ($v) {
7878
return $this->formatStructForApi($v);
79+
},
80+
'severity' => function ($v) {
81+
return array_flip(Logger::getLogLevelMap())[strtoupper($v)];
7982
}
8083
], [
8184
'google.protobuf.Duration' => function ($v) {
8285
return $this->formatDurationForApi($v);
8386
},
87+
'google.protobuf.Timestamp' => function ($v) {
88+
return $this->formatTimestampForApi($v);
89+
}
8490
]);
8591
$this->optionsValidator = new OptionsValidator($this->serializer);
8692
}

Logging/tests/Unit/Connection/GapicTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,9 @@ public function methodProvider()
119119
],
120120
'httpRequest' => [
121121
'latency' => ['seconds' => 1, 'nanos' => 0]
122-
]
122+
],
123+
'timestamp' => ['seconds' => 100],
124+
'severity' => 100,
123125
];
124126
$sinkData = [
125127
'name' => $value,
@@ -163,7 +165,9 @@ public function methodProvider()
163165
],
164166
'httpRequest' => [
165167
'latency' => '1.0s'
166-
]
168+
],
169+
'timestamp' => date('Y-m-d H:i:s', 100),
170+
'severity' => 'DEBUG',
167171
]
168172
]
169173
],

0 commit comments

Comments
 (0)