hanaro (하나로) is a non-invasive logging configurator.
This README is only a high-level introduction to hanaro. For more detailed documentation, please view the official docs at https://hanaro.readthedocs.io.
Installation
hanaro can be installed from pypi through the usual means:
pip install hanaro
Usage
Let's try a "learn by example" approach:
import hanaro
hanaro.configure_logging()
logger = hanaro.get_logger()
logger.info('Hello, World!')
In the above example hanaro is used to apply a basic logging configuration and then create a Logger instance that identifies the current module. No explciit configuration is provided, so the default behavior is to allocate a console handler with a logfmt that allows logging back-ends (GTM, ELK, etc) to properly handle mult-line log entries (typically error logs containing stack traces.)
When executed the program outputs the following:
[2025-12-31T12:34:56] Hello, World! level=INFO source=__main__
Configuration
Configuration handling is performed using appsettings2 which supports json, toml, yaml, environment variable, and command-line args to provide a unified configuration. For demonstration, assume the following is the content of appsettings.json:
{
"logging": {
"level": "INFO",
"format": "[%(asctime)s] %(message)s level=%(levelname)s source=%(name)s %(metadata)s",
"datefmt": "%Y-%m-%dT%H:%M:%S",
"handlers": [
{
"type": "console",
"level": "DEBUG"
},
{
"type": "file",
"level": "DEBUG",
"path": "logs/",
"name": "debug.log",
"max_size": "4KiB",
"max_count": 10,
"format": "[%(asctime)s] level=%(levelname)s %(message)s source=\"%(name)s\" func=\"%(funcName)s\" %(metadata)s"
},
{
"type": "custom",
"class": "myapp.mymodule.myhandler",
"level": "WARNING",
"format": "msg=\"%(message)s\" level=\"%(levelname)s\" source=\"%(name)s\" func=\"%(funcName)s\" %(metadata)s"
}
],
"filters": {
"asyncio": {
"level": "WARNING"
},
"mysql.*": {
"level": "WARNING"
},
"urllib3.*": {
"level": "WARNING"
},
"websockets.*": {
"level": "WARNING"
}
}
}
}
Modifying the prior example to use such a configuration is trivial:
import appsettings2
import hanaro
hanaro.configure_logging(
appsettings2.get_configuration()
)
logger = hanaro.get_logger()
logger.info('Hello, World!')
QA and DevOps will find that appsettings2.get_configuration makes it very easy to override configuration with just the one line of code.
Notables..
Things not obvious given the example above:
- All configuration options are optional, you can reduce the config to specify only the features you wish to customize.
- If no configuration (or a partial configuration) is provided,
configure_logging()will apply defaults. - If no handlers are configured, a default handler for "console" logging is configured.
- If no format is specified, a default that is friendly toward GTM/ELK/etc parsing is used.
- hanaro only has a single direct dependency:
appsettings2.
Contact
You can reach me on Discord or open an Issue on Github.
Metadata
Release files for hanaro 2.0.1
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 | Actions |
|---|---|---|---|---|
| hanaro-2.0.1.tar.gz | 15.1 kB | Without provenance | Details for hanaro-2.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hanaro-2.0.1-py3-none-any.whl | Python 3 | none | any | Details for hanaro-2.0.1-py3-none-any.whl |
Total release size: 31.7 kB
Release files / hanaro-2.0.1.tar.gz
| Download URL | hanaro-2.0.1.tar.gz |
|---|---|
| Size | 15.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8d18fa3ed105caed0ff6d14fa9f506661a68158c635b35f7a287669ff0f0ff5c
|
|
BLAKE2b-256 checksum How to use checksums |
33df3782af418227761e56a6d9343c3c4b96d643eb7d395529e8baa2295f3961
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.15
|
Release files / hanaro-2.0.1-py3-none-any.whl
| Download URL | hanaro-2.0.1-py3-none-any.whl |
|---|---|
| Size | 16.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
24ec865ad2abf44083bfad6fdfe753445590dda9f30a8da765f3d1101544711e
|
|
BLAKE2b-256 checksum How to use checksums |
b8a14d5d2d24c491f6a7d1cabd6ecb9b3bf825361df764fb594067b0fb94b2a5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.15
|
Security for hanaro 2.0.1
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.