BewareMyPower opened a new issue #12325:
URL: https://github.com/apache/pulsar/issues/12325
**Describe the bug**
After creating the `AuthOauth2` object in main thread, the logger cannot be
customized. It's because there's a `LOG_DEBUG` call in
`ClientCredentialFlow::initialize`:
```c++
LOG_DEBUG("Received well-known configuration data " << issuerUrl_
<< " code " << response_code);
```
It will trigger the creation of `Logger` before `setLogger` works. Once a
thread local logger was created, it could not change anymore.
**To Reproduce**
```c++
#include <iostream>
#include <pulsar/Client.h>
#include <lib/LogUtils.h>
DECLARE_LOG_OBJECT()
using namespace pulsar;
int main() {
ParamMap params;
// Replace following configs with the real world params or just fake
params
params["issuer_url"] = "...";
params["client_id"] = "...";
params["client_secret"] = "...";
params["audience"] = "...";
ClientConfiguration conf;
conf.setLogger(new ConsoleLoggerFactory(Logger::LEVEL_DEBUG));
conf.setAuth(AuthOauth2::create(params));
LOG_DEBUG("DEBUG 1");
Client client("pulsar://localhost:6650", conf);
LOG_DEBUG("DEBUG 2");
Producer producer;
Result result =
client.createProducer("persistent://public/default/my-topic", producer);
if (result != ResultOk) {
LOG_ERROR("Error creating producer: " << result);
return -1;
}
client.close();
}
```
Even if the debug console logger was configured, no debug logs could be
seen. After remove `conf.setAuth(AuthOauth2::create(params));`, the debug logs
occurred again.
**Expected behavior**
The behavior might be correct. But we need a solution to avoid this case.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]