HexaLog
HexaLog is a logging port and set of opinionated adapters meant to simplify using a logger in a hexagonal architecture.
Why
In hexagonal architecture dependencies external dependencies should be injected to adapters and the service at runtime. This means business logic doesn't directly depend on external concerns which can (arguably) make code easier to test and maintain. A logger is an external dependency, therefor it to can be passed into a service or adapter at runtime.
Installation
pip install hexalog
Usage
For production environments hexalog wraps structlog and provides a structlog adapter.
From development environments hexalog wraps the standard library logging module and provides a logging adapter.
If you have some service or adapter then make the logger port a dependency of that class:
from hexalog.ports import Logger
class SomeService:
def __init__(self, logger: Logger):
self.logger = logger
def do_something(self):
self.logger.info("Doing something")
Then in your entrypoint to the application where you wire up your dependencies you can inject a logger like so:
import os
from some_service import SomeService
from hexalog.adapters.struct_logger import StructLogger
log_level = os.getenv("LOG_LEVEL", "DEBUG")
logger = StructLogger(log_level=log_level)
# If you want to use the cli logger then you just need to inject that one
# logger = CliLogger(log_level=log_level)
service = SomeService(logger=logger)
service.do_something()
See the examples directory for more information.
Metadata
Release files for HexaLog 0.6.0
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 | |
|---|---|---|---|---|
| hexalog-0.6.0.tar.gz | 3.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| hexalog-0.6.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.0 kB
Release files / hexalog-0.6.0.tar.gz
| Download URL | hexalog-0.6.0.tar.gz |
|---|---|
| Size | 3.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3e858568b5d58a0e469cafab986f115e9af42bbfe4264cf2631ce42403d9ee5c
|
|
BLAKE2b-256 checksum How to use checksums |
59626c4366ba7aa50b004be82db5e3657a3a6006d6d708803b1ec37d4e605381
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.6
|
Release files / hexalog-0.6.0-py3-none-any.whl
| Download URL | hexalog-0.6.0-py3-none-any.whl |
|---|---|
| Size | 4.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c262564ed87bd838e6f3c611c39e87db759c13d00eae1da5188d86d483ddfb33
|
|
BLAKE2b-256 checksum How to use checksums |
78e78389c87490f3e9f3dffe158064e2ec86605160c00177eaf0ee8508b60fc9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.6
|
Security for HexaLog 0.6.0
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.