|
1 | 1 | Useful Python Utils |
2 | 2 | ============================================================================== |
3 | 3 |
|
4 | | -.. image:: https://travis-ci.org/WoLpH/python-utils.svg?branch=master |
5 | | - :target: https://travis-ci.org/WoLpH/python-utils |
| 4 | +.. image:: https://github.com/WoLpH/python-utils/actions/workflows/main.yml/badge.svg?branch=master |
| 5 | + :target: https://github.com/WoLpH/python-utils/actions/workflows/main.yml |
6 | 6 |
|
7 | 7 | .. image:: https://coveralls.io/repos/WoLpH/python-utils/badge.svg?branch=master |
8 | 8 | :target: https://coveralls.io/r/WoLpH/python-utils?branch=master |
@@ -36,16 +36,22 @@ Installation: |
36 | 36 |
|
37 | 37 | The package can be installed through `pip` (this is the recommended method): |
38 | 38 |
|
| 39 | +.. code-block:: bash |
| 40 | +
|
39 | 41 | pip install python-utils |
40 | 42 | |
41 | 43 | Or if `pip` is not available, `easy_install` should work as well: |
42 | 44 |
|
| 45 | +.. code-block:: bash |
| 46 | +
|
43 | 47 | easy_install python-utils |
44 | 48 | |
45 | 49 | Or download the latest release from Pypi (https://pypi.python.org/pypi/python-utils) or Github. |
46 | 50 |
|
47 | 51 | Note that the releases on Pypi are signed with my GPG key (https://pgp.mit.edu/pks/lookup?op=vindex&search=0xE81444E9CE1F695D) and can be checked using GPG: |
48 | 52 |
|
| 53 | +.. code-block:: bash |
| 54 | +
|
49 | 55 | gpg --verify python-utils-<version>.tar.gz.asc python-utils-<version>.tar.gz |
50 | 56 |
|
51 | 57 | Quickstart |
@@ -226,6 +232,22 @@ Or add a correclty named logger to your classes which can be easily accessed: |
226 | 232 | import logging |
227 | 233 | my_class.log(logging.ERROR, 'log') |
228 | 234 |
|
| 235 | +Alternatively loguru is also supported. It is largely a drop-in replacement for the logging module which is a bit more convenient to configure: |
| 236 | + |
| 237 | +First install the extra loguru package: |
| 238 | + |
| 239 | +.. code-block:: bash |
| 240 | +
|
| 241 | + pip install 'python-utils[loguru]' |
| 242 | +
|
| 243 | +.. code-block:: python |
| 244 | +
|
| 245 | + class MyClass(Logurud): |
| 246 | + ... |
| 247 | +
|
| 248 | +Now you can use the `Logurud` class to make functions such as `self.info()` |
| 249 | +available. The benefit of this approach is that you can add extra context or |
| 250 | +options to you specific loguru instance (i.e. `self.logger`): |
229 | 251 |
|
230 | 252 | Convenient type aliases and some commonly used types: |
231 | 253 |
|
|
0 commit comments