Skip to main content

logmixin

Description

This is an extremely small Python package (one module, ~40 lines) to enable quick and easy logging within class methods.

Usage

It defines a mixin class that adds a get_logger method to your class. This method returns a logger with the name of your module, class, and method that called it. For example, suppose you have a module called my_module.py with these contents:

import logging
from logmixin import LogMixin


class MyClass(LogMixin):
    """A class with logging enabled."""
    def my_method(self):
        self.get_logger().info("Hello, world!")


if __name__ == "__main__":
    logging.basicConfig(level=logging.INFO)
    MyClass().my_method()

If you run this file, you will see the following output:

INFO:my_module.MyClass.my_method:Hello, world!

Installation

You can install this package from PyPI:

pip install logmixin

License

MIT

Metadata

Release files for logmixin 0.1.4

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

Source distribution (sdist)

Source distribution for logmixin 0.1.4
File Size Uploaded
logmixin-0.1.4.tar.gz 3.0 kB Details

Built distribution (wheel)

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

Total release size: 7.0 kB

Release files / logmixin-0.1.4.tar.gz

Download URL logmixin-0.1.4.tar.gz
Size 3.0 kB
Tags Source
SHA-256 checksum
How to use checksums
1d8db38dc053536de96fcfc021fd7db29b5694a0a25799d17602e7a1855c197c
BLAKE2b-256 checksum
How to use checksums
f2d5dc706eb2c4a8ed9181403b4c5e436d19dfe58047cac935d2ad0f61e5be6f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.2 CPython/3.11.1 Darwin/22.1.0

Release files / logmixin-0.1.4-py3-none-any.whl

Download URL logmixin-0.1.4-py3-none-any.whl
Size 4.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
707aff0810d3be33eb119e2355ec9ce4fdd2aeba5249d7a5492bb95e65c5b005
BLAKE2b-256 checksum
How to use checksums
37c5398db881feec6fa5b841986847f1f0502f66b1d098b20d3605ece3436150
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.2 CPython/3.11.1 Darwin/22.1.0

Release history Release notifications | RSS feed

This release

0.1.4 This release

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.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