Skip to main content

Misc utilities for python projects

Project description

miscutils

Utilities for working with python projects.

Usage

logging_config

Default configuration for structlog.

Configure json logging at the INFO level:

from miscutils.logging_config import default_logging, LogFormat, Verbosity

default_logging(Verbosity.INFO, LogFormat.JSON)

Configure text logging at the DEBUG level:

from miscutils.logging_config import default_logging, LogFormat, Verbosity

default_logging(Verbosity.DEBUG, LogFormat.TEXT)

Configure text logging at the DEBUG level and filter out external loggers:

from miscutils.logging_config import default_logging, LogFormat, Verbosity

default_logging(Verbosity.DEBUG, LogFormat.TEXT, ["extern_logger_1"])

Log timing information for a function

Decorator to add timing information to the logs:

from miscutils.timer import timer

import structlog

@timer(structlog.get_logger(__name__))
def some_function():
    pass

Testing

Testing is done via pytest.

$ pip install -r requirements.txt
$ pytest

To get code coverage information, you can run pytest directly.

$ pip install -r requirements.txt
$ pytest --cov=src --cov-report=html

This will generate an html coverage report in htmlcov/ directory.

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

misc-utils-py-0.1.0.tar.gz (4.3 kB view hashes)

Uploaded Source

Built Distribution

misc_utils_py-0.1.0-py3-none-any.whl (8.4 kB view hashes)

Uploaded Python 3

Supported by

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