python-logging
The a8logging function is a utility for logging events in Python projects. It provides a consistent and flexible way to log successes, errors, and other events, and supports multiple output options such as logging to a file or pushing the logs to Elasticsearch.
Features
- Logs events with the following fields: message, function name, project name, version, and status (success or error).
- Optionally logs error tracebacks in case of errors.
- Supports logging to a file, with the option to specify the file name and log rotation settings.
- Supports logging to Elasticsearch, with the option to specify the Elasticsearch host and port, and other connection settings.
- Provides a generalized function that can be easily integrated into any Python project.
Installation
To install the log_event function, you will need to install the following dependencies:
- logging: A built-in Python library for logging events.
- traceback: A built-in Python library for printing stack traces in case of errors.
- uuid: A built-in Python library for generating unique IDs.
- elasticsearch: A third-party library for pushing logs to Elasticsearch.
- You can install these dependencies by running the following command:
pip install -r requirements.txt
Usage
To use the log_event function, you will need to import it into your Python code and call it with the appropriate arguments. Here is an example of how to log a success event:
from a8logging import a8logging
a8logging('success', "Test message", function_name='test_function', project_name='test_project', version='1.0.0')
This will log a success event with the message 'Test message', the function name 'test_function', the project name 'test_project', and the version '1.0.0'. To log an error event, you can pass the error argument with an Exception object:
from a8logging import a8logging
try:
# Some code that may throw an exception
raise Exception('Test error')
except Exception as e:
a8logging('error', "Test error", function_name='test_function', error=e, project_name='test_project', version='1.0.0')
This will log an error event with the message 'Test error', the function name 'test_function', the project name 'test_project', and the version '1.0.0'. The error traceback will also be logged.
To log to a file, you can pass the save_to_file argument with a value of True and the file_name argument with the desired file name:
from a8logging import a8logging
a8logging('success', "Test message", function_name='test_function', project_name='test_project', version='1.0.0', save_to_file=True, file_name='test.txt')
This will log the event to the file 'test.txt'.
Metadata
Release files for a8logging 1.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| a8logging-1.0.6.tar.gz | 3.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| a8logging-1.0.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.7 kB
Release files / a8logging-1.0.6.tar.gz
| Download URL | a8logging-1.0.6.tar.gz |
|---|---|
| Size | 3.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
566cc03d077a1545b61be0793b2b9ec944a82d36ef192887eebc6b11bdad2155
|
|
BLAKE2b-256 checksum How to use checksums |
af992af7dab2d550b76a34946fc6d1ca899e05aa7db6dd341768221f868f71e5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.6
|
Release files / a8logging-1.0.6-py3-none-any.whl
| Download URL | a8logging-1.0.6-py3-none-any.whl |
|---|---|
| Size | 3.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ffd3f78da1e69c92449072b976bedda95b776b430fffa1279909265e74568376
|
|
BLAKE2b-256 checksum How to use checksums |
3d75272fc102fd557050a13bfcb46129b7c92f841e2f0cd78fc5c6ecaae71c5c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.6
|
Security for a8logging 1.0.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.