Skip to main content

Python Package Logging Assistant.

Project description

py-package-logging

Install

pip install py-pkg-logging

Use

Package-level logging

Set up package-level logging in pkg/__init__.py

# -- set up logging: ----------------------------------------------------------
import logging as _logging
import py_pkg_logging as _ppl

name = "pkg" # define this on a per-package basis

_log_config = _ppl.LogConfig(name = name, log_file=f"{name}.log")

_logger = _logging.getLogger(f'{name}.{__name__}')
_logger.info(f"Logs for {name} will be saved to: {_log_config.log_fpath}")
_logger.debug(f"Importing from local install location: {__file__}")

# the rest of your package-level import statements

Example use of in-line function-call logging:

# -- set up logger: -----------------------------------------------------------
import py_pkg_logging
import logging

logger = logging.getLogger(__name__)


@py_pkg_logging.log_function_call(logger)
def persistent_executer(a, b, c):
    return (a + b) * c

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

py_pkg_logging-0.0.2.tar.gz (3.1 kB view hashes)

Uploaded Source

Built Distribution

py_pkg_logging-0.0.2-py3-none-any.whl (3.9 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