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:
- The following dependencies are required:
mms-python-logger>=0.0.1
- Import module:
from mms_alice_python_logger_pkg.alice_log_handler import Logger
- Initalize the logger:
Cloud Function Logging:
logger = Logger(trace_id, project_id, function_name, resource_type)
logger = Logger('lksjdfl98', 'v135-5683-alice-ksk-explore', 'cf-sample-implementation', 'cloud_function')
App Engine Logging:
logger = Logger(trace_id, project_id, module_id, version_id, resource_type)
logger = Logger('lksjdfl98', 'v135-5683-alice-ksk-explore', 'app-flex-sample-service', 'v0.0.1', 'gae_app')
The following resource_types are supported:
Cloud Function: 'cloud_function' App Engine: 'gae_app'
When resource type is unrecoginzable logs will be processed to 'Global'
- 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
Important
This log tool only works in App Engine Standard/Flexible and Cloud Function 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
Built Distribution
Hashes for mms_python_logger-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d0f50bfa07dcf21769f3280c109d3c4511a0df0f7fd254b8ef3679f0cf98cfa5 |
|
MD5 | f2df708089de317e727ce1fcc397a3b0 |
|
BLAKE2b-256 | 1aa8ea3da0299faa886bf462cace8120a41d1b90895cbe1d33a26759068fd1b6 |