Skip to content

Commit f5a02ea

Browse files
committed
task: Remove import of colllections.Callable (#54)
1 parent e93462e commit f5a02ea

2 files changed

Lines changed: 30 additions & 12 deletions

File tree

CHANGELOG.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22
CHANGELOG
33
==========
44

5+
`0.5.2`_ (2022-4-14)
6+
---------------------
7+
8+
* Remove import from ``collections.Callable`` in ``log_handler.py`` so it works above Python 3.8 (`#54`_)
9+
10+
11+
`0.5.1`_ (2022-4-14)
12+
---------------------
13+
14+
* Could not publish to PyPi because of some wierd rendering issue in the README...
15+
516
`0.5.0`_ (2022-4-14)
617
---------------------
718

src/quickbase_client/tools/log_handler.py

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import logging
22
import threading
3-
from collections import Callable
43
from datetime import datetime
54

65
from quickbase_client import QuickbaseTableClient
@@ -13,11 +12,11 @@
1312
class QuickbaseLogHandler(logging.Handler):
1413
"""Class for sending logs to a specific Quickbase table.
1514
16-
You supply it with a table client to the logs table, and the handler will send logs to that
17-
table in a non-blocking background thread.
15+
You supply it with a table client to the logs table, and the handler will send logs
16+
to that table in a non-blocking background thread.
1817
19-
This uses the higher-level QuickbaseTableClient APIs. So you will have to create a class for
20-
your table you want to send logs to.
18+
This uses the higher-level QuickbaseTableClient APIs. So you will have to
19+
create a class for your table you want to send logs to.
2120
"""
2221

2322
def __init__(self, logs_table_client: QuickbaseTableClient):
@@ -35,9 +34,17 @@ def __init__(self, logs_table_client: QuickbaseTableClient):
3534
super().__init__()
3635

3736
@staticmethod
38-
def with_record_factory(
39-
logs_table_client: QuickbaseTableClient, record_factory: Callable
40-
):
37+
def with_record_factory(logs_table_client: QuickbaseTableClient, record_factory):
38+
"""Create a logger using a function to make records.
39+
40+
:param logs_table_client:
41+
The QuickbaseTableClient for the logs to go to.
42+
43+
:param record_factory:
44+
A function which takes a `logging.LogRecord` and creates the relevant
45+
record (instance of a :class:`~QuickbaseTable`).
46+
"""
47+
4148
class _CustomRecordFactoryHandler(QuickbaseLogHandler):
4249
def record_factory(self, record: logging.LogRecord):
4350
return record_factory(record)
@@ -46,9 +53,9 @@ def record_factory(self, record: logging.LogRecord):
4653

4754
def record_factory(self, record: logging.LogRecord):
4855
"""
49-
Create a :class:`~QuickbaseTable` record object given a LogRecord. By default, this
50-
assumes the associated table, under the handlers table client, has properties `when`,
51-
`level`, and `message`.
56+
Create a :class:`~QuickbaseTable` record object given a LogRecord. By default,
57+
this assumes the associated table, under the handlers table client, has
58+
properties ``when``, ``level``, and ``message``.
5259
5360
:param record: The logging.LogRecord.
5461
:return: A QuickbaseTable record object.
@@ -60,7 +67,7 @@ def record_factory(self, record: logging.LogRecord):
6067
)
6168

6269
def emit(self, record):
63-
"""Calls :meth:`~record_factory` and starts a separate thread to send it to Quickbase."""
70+
"""Calls :meth:`~record_factory` and starts a thread to send it to Quickbase."""
6471
t = threading.Thread(target=self._do_emit, args=[record])
6572
t.start()
6673

0 commit comments

Comments
 (0)