Skip to main content

A custom MMS/Alice log module for python

Project description

mms-alice-python-logger

Log Module for MMS/Alice standarzised log purposes

This is a package for writing logs to GCP App Engine.

How to use:

1. Import module:

from mms_alice_python_logger_pkg.alice_log_handler import Logger

Please also add the following to the requirements.txt or install the pip packages on your VM:

google-cloud-logging==1.8.0
mms-python-logger>=0.0.2

2. Initalize the logger:

Cloud Function Logging:

logger = Logger(run_id, project_id, function_name, resource_type)
logger = Logger(run_id='lksjdf2', project_id='my-project-id', function_name='ppx-price-updates-de-gcs-bq', resource_type='cloud_function')

App Engine Logging:

logger = Logger(run_id, project_id, module_id, version_id, resource_type)
logger = Logger(run_id='lksjdfl98', project_id='v135-5683-alice-ksk-explore', module_id='app-flex-sample-service', version_id='v0.0.1', resource_type='gae_app')

Compute Engine:

logger = Logger(run_id, project_id, resource_type)
logger = Logger(run_id='lksjdfl98', project_id='v135-5683-alice-ksk-explore', resource_type='gce_instance')

The following resource_types are supported:

Cloud Function: 'cloud_function' App Engine: 'gae_app' Compute Engine: 'gce_instance'

When resource type is unrecoginzable logs will be processed to 'Global'

3. Use the logger:

logger.info('your message')
logger.warning('your message')
logger.error('your message')
logger.critical('your message')
logger.debug('your message')

The logs are visible in Stackdriver Logging via GAE Application -> Module_id -> Version_id for App Engine. Or under Cloudfunctions -> Function_id Or under GCE VM Instance -> Instance_id

Important

This log tool only works in App Engine Standard/Flexible, Cloud Function and Compute Engine environment.

For local testing do not initialize the logger as it would ran into errors because of the missing GCP context.

How we log

We initialize the logger only in the "app.py" file. From there every log entry will be written - Modules used within app.py need to return the exceptions to the caller so error etc. get logged at one central point within app.py.

Project details


Download files

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

Source Distribution

mms_python_logger-0.0.4.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mms_python_logger-0.0.4-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file mms_python_logger-0.0.4.tar.gz.

File metadata

  • Download URL: mms_python_logger-0.0.4.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.7

File hashes

Hashes for mms_python_logger-0.0.4.tar.gz
Algorithm Hash digest
SHA256 bb9020baf48ef3df2a3177e1006e053d6b5629ad2627422e3dfcbfe9424ca066
MD5 4ac79ec4a71bc88e27f6eb8a5cc39d29
BLAKE2b-256 ed8da675008b244650bdb0b336d453ddbb79d33142d2094209271d36cf406101

See more details on using hashes here.

File details

Details for the file mms_python_logger-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: mms_python_logger-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.7

File hashes

Hashes for mms_python_logger-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 31fd4cb38fd45ac465cdbe95ed584cf57f846464da3e4cbda349d185e4320617
MD5 120c95b308247ea2296de82430ad760a
BLAKE2b-256 ee822109dc4fb8473b94b4c7c24bfafd164800f3acb77fcb75183d6eff270a0a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page