Skip to main content

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 1.3.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hanaro 1.3.6
File Size Uploaded
hanaro-1.3.6.tar.gz 14.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for hanaro 1.3.6
File Interpreter ABI Platform
hanaro-1.3.6-py3-none-any.whl Python 3 none any Details

Total release size: 30.5 kB

Release files / hanaro-1.3.6.tar.gz

Download URL hanaro-1.3.6.tar.gz
Size 14.7 kB
Tags Source
SHA-256 checksum
How to use checksums
2a12753149646bdfd6cc06405c44fc40213fbb34a5bd440f5c1cadfe48496879
BLAKE2b-256 checksum
How to use checksums
d49382d89d18b1b3b2ca246582b0b3d1ba3719ede7b0d9a547377418b8329f82
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.15

Release files / hanaro-1.3.6-py3-none-any.whl

Download URL hanaro-1.3.6-py3-none-any.whl
Size 15.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c5d7e76c451cbe57ee7c4f4245486fb423678b40fc09038e7f59dfa7178f7cef
BLAKE2b-256 checksum
How to use checksums
68138c6b6be140ec1cddd7e97f72b901579a4e09062aa7fd80765c5c1622847d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.15

Release history Release notifications | RSS feed

2.0.1

2 release files

2.0.0

2 release files

This release

1.3.6 This release

2 release files

1.3.2

2 release files

1.3.0

2 release files

1.2.10

2 release files

1.2.9

2 release files

1.2.4

2 release files

1.2.0

2 release files

1.0.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.2

2 release files

0.1.0

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page