apache / apache/pulsar-client-cpp

[Bug] CPP/Python Logger cannot be changed between different clients. First one set stays for all Pulsar Clients

未关闭
#333 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
C++
星标
71
派生
90
平均合并
2 小时 33 分钟
30 天内合并 PR
3

描述

### Search before asking

- [X] I searched in the [issues](https://github.com/apache/pulsar-client-cpp/issues) and found nothing similar.

### Version

Pulsar 3.1.0
Pulsar-Client Python 3.3.0
OS : Ubuntu 20.04

### Minimal reproduce step

```python
import logging
import pulsar

if __name__ == '__main__':
logger_1 = logging.getLogger('pulsar_logger_1')
hdlr = logging.StreamHandler()
log_format = "pulsar_logger_1: [%(asctime)s] [%(levelname)s]: %(message)s"
logger_1.setLevel(logging.INFO)
formatter = logging.Formatter(fmt=log_format)
hdlr.setFormatter(formatter)
logger_1.addHandler(hdlr)
logger_1.propagate = False
client = pulsar.Client('pulsar://localhost:6650', logger=logger_1)
consumer = client.subscribe('my-topic', 'my-subscription')
consumer.close()
client.close()
logger_2 = logging.getLogger('pulsar_logger_2')
hdlr = logging.StreamHandler()
log_format = "pulsar_logger_2: [%(asctime)s] [%(levelname)s]: %(message)s"
logger_2.setLevel(logging.INFO)
formatter = logging.Formatter(fmt=log_format)
hdlr.setFormatter(formatter)
logger_2.addHandler(hdlr)
logger_2.propagate = False
client_2 = pulsar.Client('pulsar://localhost:6651', logger=logger_2)
consumer_2 = client_2.subscribe('my-topic', 'my-subscription2')
consumer_2.close()
client_2.close()
client_3 = pulsar.Client('pulsar://localhost:6650', logger=None)
consumer_3 = client_3.subscribe('my-topic', 'my-subscription3')
consumer_3.close()
client_3.close()
```

### What did you expect to see?

I would expect the first client to use pulsar_logger_1, the second to use pulsar_logger_2 and the third one to use the default logger.

### What did you see instead?

All clients use pulsar_logger_1

### Anything else?

It seems that subsequent defined pulsar clients fail to set the logger and keep the first one defined instead.

### Are you willing to submit a PR?

- [ ] I'm willing to submit a PR!

贡献指南

打开贡献指南

调研方向

首先针对 Pulsar C++ client 运行 Python reproduction,并跟踪传递给每个 Pulsar Client 的 logger 是如何被保留的。当不同的客户端使用为其提供的 logger,而传入 logger=None 的客户端使用 default logger(如 reproduction 输出所示)时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
cpp, python
领域
api, backend
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。