HDX Python Utilities
Project description
Usage
The library has detailed API documentation which can be found here: http://ocha-dap.github.io/hdx-python-utilities/. The code for the library is here: https://github.com/ocha-dap/hdx-python-utilities.
Configuring Logging
If you wish to change the logging configuration from the defaults, you will need to call setup_logging with arguments.
from hdx.hdx_logging import setup_logging ... logger = logging.getLogger(__name__) setup_logging(KEYWORD ARGUMENTS)
KEYWORD ARGUMENTS can be:
Choose |
Argument |
Type |
Value |
Default |
---|---|---|---|---|
One of: |
logging_config_dict |
dict |
Logging configuration dictionary |
|
or |
logging_config_json |
str |
Path to JSON Logging configuration |
|
or |
logging_config_yaml |
str |
Path to YAML Logging configuration |
Library’s internal logging_configuration.yml |
One of: |
smtp_config_dict |
dict |
Email Logging configuration dictionary |
|
or |
smtp_config_json |
str |
Path to JSON Email Logging configuration |
|
or |
smtp_config_yaml |
str |
Path to YAML Email Logging configuration |
Do not supply smtp_config_dict, smtp_config_json or smtp_config_yaml unless you are using the default logging configuration!
If you are using the default logging configuration, you have the option to have a default SMTP handler that sends an email in the event of a CRITICAL error by supplying either smtp_config_dict, smtp_config_json or smtp_config_yaml. Here is a template of a YAML file that can be passed as the smtp_config_yaml parameter:
handlers: error_mail_handler: toaddrs: EMAIL_ADDRESSES subject: "RUN FAILED: MY_PROJECT_NAME"
Unless you override it, the mail server mailhost for the default SMTP handler is localhost and the from address fromaddr is noreply@localhost.
To use logging in your files, simply add the line below to the top of each Python file:
logger = logging.getLogger(__name__)
Then use the logger like this:
logger.debug('DEBUG message') logger.info('INFORMATION message') logger.warning('WARNING message') logger.error('ERROR message') logger.critical('CRITICAL error message')
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
Hashes for hdx-python-utilities-1.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f6d62c16262977b8a4da49ed772b408aaf875bae8e350a0c3140336bfd7eaec |
|
MD5 | 2806c115760fee3b5789a685ff81d3b9 |
|
BLAKE2b-256 | 5b688dc310eae39fcb215231cd1a5a3adcf467a7c2e993b82765de8d686683f9 |
Hashes for hdx_python_utilities-1.0.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 159e5fdce0f53b9ffdb016fea5a62ea318a9cd57fddce06ee4af2b80c18cbf27 |
|
MD5 | 308dbfbda3f6edcfd4d25f5f11d52926 |
|
BLAKE2b-256 | 48ad0426d6e8cecb5eee9ab8db5328fcbb6cf92524861cc0e747c97bff31b495 |