Skip to main content

A fast, flexible Python logging library with sync and async support.

Project description

logry

Python logging library with native async support, multiple independent loggers, and zero external dependencies.

Installation

pip install logry

Requires Python 3.8 or higher.


Quick Start

from logry import log

log.info("Server started")
log.success("Connected to database")
log.warning("Memory usage at 80%")
log.error("Connection dropped")
log.debug("user_id=123")

Output:

[2026-03-09 10:23:45] INFO    | Server started
[2026-03-09 10:23:46] SUCCESS | Connected to database
[2026-03-09 10:23:47] WARNING | Memory usage at 80%
[2026-03-09 10:23:48] ERROR   | Connection dropped
[2026-03-09 10:23:49] DEBUG   | user_id=123

Log Levels

Level Method Color
DEBUG log.debug() Grey
INFO log.info() Blue
SUCCESS log.success() Green
WARNING log.warning() Yellow
ERROR log.error() Red

Usage

Global logger

The simplest way to use logry is via the built-in global log instance, which is ready to use immediately after import.

from logry import log

log.info("Application initialized")
log.error("Unexpected error")

Named loggers

Each Logger instance is fully independent and can be configured separately.

from logry import Logger

db  = Logger("database")
api = Logger("api")
bot = Logger("bot")

db.info("Connected to PostgreSQL")
api.error("Request timeout")
bot.success("Polling started")

Output formats

Three formats are available: pretty (default), minimal, and json.

pretty outputs colored lines with a timestamp, suited for development. minimal outputs level and message only. json outputs structured single-line JSON, suited for production log collection.

log = Logger("app", format="json")
log.info("Structured output")
{"time": "2026-03-09 10:23:45", "level": "INFO", "name": "app", "message": "Structured output"}

File output

log = Logger("app")
log.set_file("app.log")

With automatic rotation:

log.set_file("app.log", max_size="10MB", backup=3)

max_size accepts values in KB or MB. When the file reaches the specified size, it is rotated and up to backup copies are retained.

Custom colors

log.set_colors({
    "debug":   "cyan",
    "info":    "blue",
    "success": "green",
    "warning": "yellow",
    "error":   "red",
})

Available colors: black, red, green, yellow, blue, magenta, cyan, white, grey.

Full configuration

All options can be set at construction time or updated at runtime.

log = Logger(
    name="app",
    level="DEBUG",
    save="app.log",
    format="pretty",
    colors=True,
    async_mode=False,
)

log.set_level("WARNING")
log.set_format("json")
log.set_file("app.log", max_size="5MB", backup=5)

Async support

When async_mode=True, log calls become coroutines and must be awaited. Output is written through an asyncio.Queue worker, keeping the event loop unblocked.

import asyncio
from logry import Logger

log = Logger("app", async_mode=True)

async def main():
    await log.ainfo("Async log entry")
    await log.aerror("Async error")

asyncio.run(main())

Benchmarks

Tested on Python 3.12 with 100,000 filtered log entries. Filtered means the log level of the call is below the logger's active level, so no output is produced — the most common scenario in production.

Library Time Messages/sec
stdlib logging 0.085s 1,176,000
logry 0.031s 3,225,000

logry avoids formatting the message string entirely when the log level is inactive (lazy formatting), which accounts for the difference.


License

MIT © riokzy

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

logry-0.1.0.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

logry-0.1.0-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

Details for the file logry-0.1.0.tar.gz.

File metadata

  • Download URL: logry-0.1.0.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.12.1.2 readme-renderer/34.0 requests/2.32.5 requests-toolbelt/1.0.0 urllib3/2.6.3 tqdm/4.67.3 importlib-metadata/8.7.1 keyring/25.7.0 rfc3986/2.0.0 colorama/0.4.6 CPython/3.13.12

File hashes

Hashes for logry-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a02b592dd280e91dd3b1aa206670c3380d36dbaf583df1f1686bb680c5057015
MD5 95361435ceb13723fdab42f62e17b941
BLAKE2b-256 a0f67b184eb803b1808b1bcb731dc0da3d5da997432378c70a7732985eff8757

See more details on using hashes here.

File details

Details for the file logry-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: logry-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.12.1.2 readme-renderer/34.0 requests/2.32.5 requests-toolbelt/1.0.0 urllib3/2.6.3 tqdm/4.67.3 importlib-metadata/8.7.1 keyring/25.7.0 rfc3986/2.0.0 colorama/0.4.6 CPython/3.13.12

File hashes

Hashes for logry-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4d2f94fa120fe1c4a68921d981704acbf493da169e89be554bafc69ebb45fa41
MD5 a239311d305f0db4e379cf15782cf7ad
BLAKE2b-256 a503570ef0aae7444bec595e13b96818932221b4036ff940df09933ef3fb5eed

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page