thanks guys! as mentioned, LogEntry.to_api_repr() is currently broken for 
this use case with the latest version of google-cloud-logging, 1.14.0. i've 
posted details on 
https://github.com/googleapis/google-cloud-python/issues/2572#issuecomment-551199704
 
(which is unfortunately closed right now).

On Thursday, November 7, 2019 at 10:56:53 AM UTC-8, Dustin Ingram wrote:
>
> You can use the LogEntry.to_api_repr() 
> <https://googleapis.dev/python/logging/latest/entries.html#google.cloud.logging.entries.LogEntry.to_api_repr>
>  
> function to get a JSON version of the LogEntry.
>
> On Thu, Nov 7, 2019 at 9:36 AM Ryan B <goo...@ryanb.org <javascript:>> 
> wrote:
>
>> Hi again! As part of migrating to Python 3, I need to migrate from 
>> logservice 
>> <https://cloud.google.com/appengine/docs/standard/python/refdocs/google.appengine.api.logservice.logservice>
>>  
>> to the StackDriver Logging API 
>> <https://cloud.google.com/logging/docs/reference/api-overview>. I have 
>> google-cloud-logging <https://pypi.org/project/google-cloud-logging/> 
>> installed, and I can successfully fetch GAE application logs with eg:
>>
>> >>> from google.cloud.logging_v2 import LoggingServiceV2Client
>> >>> entries = LoggingServiceV2Client().list_log_entries((
>> 'projects/brid-gy',),
>>          filter_='resource.type="gae_app" AND protoPayload.@type="
>> type.googleapis.com/google.appengine.logging.v1.RequestLog"')
>> >>> print(next(iter(entries)))
>> proto_payload {
>>   type_url: "type.googleapis.com/google.appengine.logging.v1.RequestLog"
>>   value: "\n\ts~brid-gy\022\0018\032R5d..."
>> }
>> ...
>>
>> This gets me a LogEntry with text application logs in the 
>> proto_payload.value field. How do I deserialize that field? I've found 
>> lots of related mentions in the docs - links below - but nothing pointing 
>> me to a google.appengine.logging.v1.RequestLog protobuf generated class 
>> anywhere that I can use, if that's even the right idea. Has anyone done 
>> this?
>>
>>
>> https://googleapis.dev/python/logging/latest/gapic/v2/types.html#google.cloud.logging_v2.types.LogEntry.proto_payload
>>
>> https://cloud.google.com/logging/docs/reference/v2/rpc/google.appengine.logging.v1#requestlog
>>
>> https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#FIELDS.proto_payload
>>
>> https://cloud.google.com/logging/docs/api/v2/resource-list#resource-indexes
>> https://groups.google.com/d/topic/google-cloud-dev/Xr6tZxOIaJY/discussion
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Google App Engine" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to google-a...@googlegroups.com <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/google-appengine/a6665355-a7e6-42d4-96c2-82090d457adf%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/google-appengine/a6665355-a7e6-42d4-96c2-82090d457adf%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/4fc5946c-5e8e-4d86-b30f-98575508e4b4%40googlegroups.com.

Reply via email to