File tree Expand file tree Collapse file tree 3 files changed +15
-4
lines changed Expand file tree Collapse file tree 3 files changed +15
-4
lines changed Original file line number Diff line number Diff line change
1
+ ## 0.1.2-wip
2
+
3
+ - ` cloudLoggingMiddleware ` uses structured logs (` jsonPayload ` ) when message is of type ` Map ` . All other messages are logged as text (` textPayload ` ).
4
+
1
5
## 0.1.1
2
6
3
7
- Require Dart 3.0
Original file line number Diff line number Diff line change @@ -98,6 +98,8 @@ final _loggerKey = Object();
98
98
99
99
/// Return [Middleware] that logs errors using Google Cloud structured logs and
100
100
/// returns the correct response.
101
+ /// Log messages of type [Map] are logged as structured logs (`jsonPayload` ).
102
+ /// All other logs messages are logged as text logs (`textPayload` ).
101
103
Middleware cloudLoggingMiddleware (String projectId) {
102
104
Handler hostedLoggingMiddleware (Handler innerHandler) => (request) async {
103
105
// Add log correlation to nest all log messages beneath request log in
@@ -229,13 +231,18 @@ class _CloudLogger extends RequestLogger {
229
231
_CloudLogger (this ._zone, this ._traceId);
230
232
231
233
@override
232
- void log (Object message, LogSeverity severity) =>
233
- _zone.print (_createLogEntry (_traceId, '$message ' , severity));
234
+ void log (Object message, LogSeverity severity) => _zone.print (
235
+ _createLogEntry (
236
+ _traceId,
237
+ message is Map ? message : '$message ' ,
238
+ severity,
239
+ ),
240
+ );
234
241
}
235
242
236
243
String _createLogEntry (
237
244
String ? traceValue,
238
- String message,
245
+ Object message,
239
246
LogSeverity severity, {
240
247
Frame ? stackFrame,
241
248
}) {
Original file line number Diff line number Diff line change 1
1
name : gcp
2
2
description : >-
3
3
Utilities for running Dart code correctly on the Google Cloud Platform.
4
- version : 0.1.1
4
+ version : 0.1.2-wip
5
5
repository : https://github.com/GoogleCloudPlatform/functions-framework-dart/tree/main/gcp
6
6
7
7
environment :
You can’t perform that action at this time.
0 commit comments