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

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.

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.1.0.tar.gz (10.4 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.1.0-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: logset-1.1.0.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for logset-1.1.0.tar.gz
Algorithm Hash digest
SHA256 3cac8bedcae139818bf515e2b2990982459e725886abed891b5c0ecbffe3ab22
MD5 3f9bb242e4c4056a6e60155a791f91ae
BLAKE2b-256 a952baf6dd5b36def240c54da07e66fc562f5658513c80905431f76924fdd7c2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: logset-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.7 kB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for logset-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 13d4f23e5e4572c0f48efa435c27cb011a24db8ebca2c81882ecee2f522619bb
MD5 ac71b5ec0b8b1f3aeee09ac52ff0e389
BLAKE2b-256 08e3d533e1bc87aed40b3211ced0b9bd3978e2228fe803bb817c04320148bf5c

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