Skip to main content

logset

Documentation Python PyPI Build Status Coverage License

Convenience functions for setting up console and file loggers with a single call.

About

Python's logging library is powerful, but comes with a steep learning curve and several common "gotchas". The logset library helps address this by providing convenience functions for setting up basic console (sys.stderr) and file logs. Each function lets you configure a log at a given logging level using a single function call.

Critically, logset requires minimal familiarity with the logging library, so developers can simply focus on what their logs should do, without needing to manage complex logging objects. The commands also help prevent issues wherein (1) messages are not logged as expected, and (2) messages are duplicated in a logging target.

Examples

Log messages to the console (sys.stderr) at a given level:

import logset

logset.console.debug("my-logger")  # Logs at the DEBUG level
logset.console.info("my-logger")   # Logs at the INFO level
# Also includes functions for the "warning", "error", and "critical" levels

Log messages to file at a given level:

logset.file.debug("my-logger", "my-file.log")
logset.file.info("my-logger", "my-file.log")
# Also includes functions for the "warning", "error", and "critical" levels

Control when log files are opened/created:

logset.file.debug("my-logger", "path/to/some/my-file.log", make_parents=True)
logset.file.debug("my-logger", "my-file.log", delay=True)

Customize the format of different logs:

logset.console.info("my-logger", "%(message)s")
logset.file.debug("my-logger", "my-file.log", "%(asctime)s - %(name)s - %(message)s)

Log to a file that rotates after reaching a maximum allowed size:

# Rotates after reaching 1MB, saving backups of the 2 most recent rotated logs
logset.file.info("my-logger", "my-file.log", rotate_bytes=1000000, backup_count=2)

Log to a file that rotates on a fixed time interval:

# Rotates after 7 days, saving backups of the 2 previous logs
logset.file.info(
    "my-logger", "my-file.log", rotate_when="D", rotate_interval=7, backup_count=2
)

Documentation

You can find more detailed examples, a user guide, and a comprehensive reference API at the project documentation.

Installation

Requires: Python 3.11+

Dependencies: None

pip install logset

Contributing / Feedback

We welcome contributions and feedback! To ask a question, suggest a feature, or report a bug, please open a new thread on our Issues tracker. If you plan to contribute code, please read the contribution guide in the docs.

License

This project is licensed under the MIT license. Refer to the license file for more details.

Release files for logset 1.1.0

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

Source distribution (sdist)

Source distribution for logset 1.1.0
File Size Uploaded
logset-1.1.0.tar.gz 10.4 kB Details

Built distribution (wheel)

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

Total release size: 26.1 kB

Release files / logset-1.1.0.tar.gz

Download URL logset-1.1.0.tar.gz
Size 10.4 kB
Tags Source
SHA-256 checksum
How to use checksums
3cac8bedcae139818bf515e2b2990982459e725886abed891b5c0ecbffe3ab22
BLAKE2b-256 checksum
How to use checksums
a952baf6dd5b36def240c54da07e66fc562f5658513c80905431f76924fdd7c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.15 {"installer":{"name":"uv","version":"0.11.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / logset-1.1.0-py3-none-any.whl

Download URL logset-1.1.0-py3-none-any.whl
Size 15.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
13d4f23e5e4572c0f48efa435c27cb011a24db8ebca2c81882ecee2f522619bb
BLAKE2b-256 checksum
How to use checksums
08e3d533e1bc87aed40b3211ced0b9bd3978e2228fe803bb817c04320148bf5c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.15 {"installer":{"name":"uv","version":"0.11.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.0

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