This is an automated email from the ASF dual-hosted git repository.
mmerli pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pulsar-client-python.git
The following commit(s) were added to refs/heads/main by this push:
new f9b2d16 [docs] Add guide to avoid logs from the default logger (#195)
f9b2d16 is described below
commit f9b2d168ae85f289d6ee043cd81791d569ba8844
Author: Yunze Xu <[email protected]>
AuthorDate: Tue Jan 16 12:13:38 2024 +0800
[docs] Add guide to avoid logs from the default logger (#195)
Fixes https://github.com/apache/pulsar-client-python/issues/194
### Motivation
When the Python logger is configured as the logger, during the exit
process of a Python script, the default logger will be used for logging
instead because the Python logger is unavailable after the interpreter
is finalized. It might lead to some unexpected outputs to standard
output.
---
pulsar/__init__.py | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/pulsar/__init__.py b/pulsar/__init__.py
index 29bb034..99b225f 100644
--- a/pulsar/__init__.py
+++ b/pulsar/__init__.py
@@ -532,6 +532,19 @@ class Client:
matches the common name on the TLS certificate presented by the
endpoint.
logger: optional
Set a Python logger for this Pulsar client. Should be an instance
of `logging.Logger`.
+ It should be noted that if the Python logger is configured, during
the termination of the Python
+ interpreter, the Python logger will be unavailable and the default
logger will be used for logging.
+ To avoid strange behavior, you'd better delete all instances
explicitly before exiting.
+
+ .. code-block:: python
+
+ import logging
+ client = Client(service_url,
logger=logging.getLogger('pulsar'))
+ producer = client.create_producer(topic)
+ # ...
+ del producer
+ del client
+
connection_timeout_ms: int, default=10000
Set timeout in milliseconds on TCP connections.
listener_name: str, optional