Пример #1
0
def load_google_client(base64_data, scopes=[]):
    if not base64_data:
        return ''

    decoded = base64.b64decode(base64_data).decode('utf-8')

    # From: https://github.com/googleapis/google-cloud-python/issues/7291#issuecomment-461135696
    with tempfile.NamedTemporaryFile() as temp:
        temp.write(decoded.encode('ascii'))
        temp.flush()
        client = LoggingClient.from_service_account_json(temp.name)

    return client
Пример #2
0
# Copyright 2018 Google Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from google.cloud.logging import Client

from core.app_data import SA_DATA, SA_FILE

if SA_DATA.get('private_key', ''):
    client = Client.from_service_account_json(SA_FILE)
else:
    client = Client()

logger_name = 'crmintapplogger'
logger = client.logger(logger_name)
Пример #3
0
import responder
from sklearn.datasets import load_iris
from google.cloud.logging import Client

client = Client.from_service_account_json("./service_account.json")
client.setup_logging()

app = responder.API()


@app.route("/")
async def index(request, response):
    import logging

    logging.info('================= Hello Logging =================')

    data = load_iris()
    response.text = str(data['DESCR'])