#NEWLINE# def _Dynamic_Flush( self , request , unused_response , request_id = None ) : #NEWLINE# #INDENT# 'Writes application-level log messages for a request to the Datastore.' #NEWLINE# group = log_service_pb . UserAppLogGroup ( request . logs ( ) ) #NEWLINE# logs = group . log_line_list ( ) #NEWLINE# appid = os . environ [ 'APPLICATION_ID' ] #NEWLINE# if ( appid in [ 'apichecker' , 'appscaledashboard' ] ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# formatted_logs = [ { #NEWLINE# #INDENT# 'timestamp' : ( log . timestamp_usec ( ) / 1000000.0 ) , #NEWLINE# 'level' : ( log . level ( ) + 1 ) , #NEWLINE# 'message' : log . message ( ) , #NEWLINE# #UNINDENT# } for log in logs ] #NEWLINE# if ( not formatted_logs ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# payload = json . dumps ( { #NEWLINE# #INDENT# 'service_name' : formatted_logs , #NEWLINE# 'host' : os . environ [ 'MY_IP_ADDRESS' ] , #NEWLINE# 'logs' : formatted_logs , #NEWLINE# #UNINDENT# } ) #NEWLINE# nginx_host = os . environ [ 'NGINX_HOST' ] #NEWLINE# logservice . SendLogsThread ( payload , nginx_host ) . start ( )