No project description provided
Project description
Custom Logger CloudCity
To unify the way we log and alert to Google Cloud Logger and Sentry, we have created this package.
Example
How to use:
- Include the package in your project by doing
pip install custom-logger-cloudcity
- Simply import the module!
Below is an examlpe how to use
import os
os.environ.update({"GOOGLE_APPLICATION_CREDENTIALS": "/Users/sebas/dev/custom-logger/service_account.json"})
os.environ.update({"CLOUD_LOGGER_NAME": "nice_test_logger"})
os.environ.update({"ENV": ""})
# We need to set the environment vars before importing the custom_logger
# You can do so as this example or just set it in the machine wide environment
import custom_logger
if __name__ == '__main__':
# A message as a string will end up in as a textPayload in Google Cloud Logging
# custom_logger.info("This is a test log in a textPayload")
custom_logger.error("not ok")
# A message as an argument will end up in as a jsonPayload in Google Cloud Logging
custom_logger.info(some_message="This is a test log in a jsonPayload")
# An example with multiple arguments
custom_logger.info(
some_message="This is a test log in a jsonPayload",
more_info="It has more info",
and_even_more="These can all be metrics and stuff",
but="We need to make sure that we catch the logging exceptions and print the whole lot",
)
# You can even nest data, as this is stored as a struct in Google Cloud Logging
custom_logger.info(amount_transfered=10, amount_failed=10, errors=["a", "b", "c"])
Project details
Release history Release notifications | RSS feed
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
Close
Hashes for custom-logger-cloudcity-0.0.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9852ba31d32ccf7e343f9d98d1df5887af6fb362eb514ae54212e5188545561d |
|
MD5 | 3c3740cf9f78b86071d2ccc9c85d62bc |
|
BLAKE2b-256 | 69454305dfbbb88f7657899d6071de14a41b3f6a37f37429c2724ace3b5f068f |
Close
Hashes for custom_logger_cloudcity-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 51b5e218a9c33d9851786667aabbdad3ef71a2f0920b033b1c9aa9620e3b9423 |
|
MD5 | ae26103386c2b395c0fb894fd8c92c05 |
|
BLAKE2b-256 | 991c5fa5ccfab6089c1140678567a0ced566e86de10ec76bab1a48a1190839d0 |