Skip to main content

Quickly configure console and file loggers

Project description

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

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.

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

logset-1.0.0.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

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

logset-1.0.0-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

Details for the file logset-1.0.0.tar.gz.

File metadata

  • Download URL: logset-1.0.0.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.13 {"installer":{"name":"uv","version":"0.11.13","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}

File hashes

Hashes for logset-1.0.0.tar.gz
Algorithm Hash digest
SHA256 1adaf3e7c8606459f604d6f3459b031a49a387822f76960d36214297b56606ca
MD5 4cc20f3bacf84beefee94f70f1eeb430
BLAKE2b-256 b33bdc535c2a24b6e901c101d98845aea210ab17da52cff6908354f6ca0fd225

See more details on using hashes here.

File details

Details for the file logset-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: logset-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 14.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.13 {"installer":{"name":"uv","version":"0.11.13","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}

File hashes

Hashes for logset-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e2302b178cb960eece667b7ded4933e8b304f702cd1a8c1bd8d0e51887f82201
MD5 7d2ebc800f21e41aed223b685560e0ab
BLAKE2b-256 5da9baf8e5d6dc09590b0be883914850d7676731baa97b86edba4754ca9f8461

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