Defines a mixin class that adds a convenient get_logger method.
Project description
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
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file logmixin-0.1.4.tar.gz.
File metadata
- Download URL: logmixin-0.1.4.tar.gz
- Upload date:
- Size: 3.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.2 CPython/3.11.1 Darwin/22.1.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1d8db38dc053536de96fcfc021fd7db29b5694a0a25799d17602e7a1855c197c
|
|
| MD5 |
044d27a0adbd1e023fd486e19dda9b83
|
|
| BLAKE2b-256 |
f2d5dc706eb2c4a8ed9181403b4c5e436d19dfe58047cac935d2ad0f61e5be6f
|
File details
Details for the file logmixin-0.1.4-py3-none-any.whl.
File metadata
- Download URL: logmixin-0.1.4-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.2 CPython/3.11.1 Darwin/22.1.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
707aff0810d3be33eb119e2355ec9ce4fdd2aeba5249d7a5492bb95e65c5b005
|
|
| MD5 |
11cc32f90377b00ea186c4df7543825b
|
|
| BLAKE2b-256 |
37c5398db881feec6fa5b841986847f1f0502f66b1d098b20d3605ece3436150
|