Skip to content

Commit 7cbfcc0

Browse files
authored
fix issue #81 (#122)
1 parent a16df3f commit 7cbfcc0

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

pkg/plugin/cloudlogging/cloudlogging.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,15 @@ func GetLogEntryMessage(entry *loggingpb.LogEntry) (string, error) {
3434
switch t := entry.GetPayload().(type) {
3535
case *loggingpb.LogEntry_JsonPayload:
3636
if msg, ok := t.JsonPayload.Fields["message"]; ok {
37-
return msg.GetStringValue(), nil
37+
msg_val := msg.GetStringValue()
38+
if msg_val == "" {
39+
// If the message field is empty, we try to marshal the entire JSON payload
40+
msg_byte_val, err := msg.MarshalJSON()
41+
if err == nil {
42+
return string(msg_byte_val), nil
43+
}
44+
}
45+
return msg_val, nil
3846
}
3947
byteArr, err := t.JsonPayload.MarshalJSON()
4048
if err != nil {

0 commit comments

Comments
 (0)