Skip to main content

A package to register GCP loggings

Project description

GCP LOGGING MANAGER

This is a simple gcp logging package where you can easily write logs to gcp stackdriver with custom parameters.

Required library

pip install --upgrade google-cloud-logging

Setting up authentication

  1. In the Cloud Console, go to the Create service account key page.
  2. From the Service account list, select New service account.
  3. In the Service account name field, enter a name.
  4. From the Role list, select Project > Owner.

GCP Stackdriver matrics

param type: Resource type to filter in Stackdriver Logging (required)
param service: Service name to filter in Stackdriver Logging (required)
param log_name: Log Name to filter in Stackdriver Logging
param region: GCP Service Region to filter in Stackdriver Logging (optional) default value region='us-east1'

Sample code

from  santodigital_gcpLogging import CloudRunLoggingClient

# Resouce must match with strackdriver resource.type (cloud_run_revision or bigquery_resource etc)
resource = 'cloud_run_revision'
name = 'santodigital-gcpLogging'
SERVICE = 'santodigital-gcpLogging'
logger = CloudRunLoggingClient(resource, SERVICE, name)

"""
:param struct: (Dict) Custom information for logging into Stackdriver Logging.
:param severity: Severity Level for the logging.
"""
def report(struct, severity='INFO'):
    logger.report(struct, severity)
    return True

if __name__ == '__main__':
    print(report({'info':'success'}, 'WARNING'))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for santodigital-gcpLogging, version 0.0.4
Filename, size File type Python version Upload date Hashes
Filename, size santodigital_gcpLogging-0.0.4-py3-none-any.whl (3.4 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size santodigital-gcpLogging-0.0.4.tar.gz (2.0 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page