-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[cpp-client] Fix for not respecting custom LoggerFactory client config #7932
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[cpp-client] Fix for not respecting custom LoggerFactory client config #7932
Conversation
|
/pulsarbot run-failure-checks |
1 similar comment
|
/pulsarbot run-failure-checks |
|
LGTM. Since the bug was introduced because there's no way to verify for custom logger currently, I thought it could be better to add an unit test for custom logger, e.g. use a custom logger to write logs to a file with a specific prefix, then read the file to check if every line has the prefix. I have written a simple test and run the tests with gtest-parallel, it works well. However, without gtest-parallel, logs of other unit tests could be written to the same file because the logger of each file was |
|
I think a better test would be to log internally and just check that, that way you're not dealing with files, etc. I'm not sure why it would affect other tests though, that seems odd. |
|
You're right, the internal field of logger should be not a The reason why the custom logger affects other tests is that the static std::atomic<LoggerFactory*> s_loggerFactory(nullptr); // setLoggerFactory changes itAnd each compile unit includes #define DECLARE_LOG_OBJECT() \
static pulsar::Logger* logger() { \
static thread_local std::unique_ptr<pulsar::Logger> threadSpecificLogPtr; \
pulsar::Logger* ptr = threadSpecificLogPtr.get(); \
if (PULSAR_UNLIKELY(!ptr)) { \
std::string logger = pulsar::LogUtils::getLoggerName(__FILE__); \
threadSpecificLogPtr.reset(pulsar::LogUtils::getLoggerFactory()->getLogger(logger)); \
ptr = threadSpecificLogPtr.get(); \
} \
return ptr; \
} |
|
Ah yes, of course. We can always change it back after test assets pass |
|
/pulsarbot run-failure-checks |
2 similar comments
|
/pulsarbot run-failure-checks |
|
/pulsarbot run-failure-checks |
|
what is preventing this from getting merged? |
|
Thanks @smazurov for the help. |
apache#7932) ### Motivation I want to use custom logging factory in cpp client ### Modifications apache#7132 broke custom logger config option. It then was identified in apache#7503 (and apache#7502) but not fixed. This PR actually fixes it by checking the right variable name. ### Verifying this change This change is a trivial rework / code cleanup without any test coverage. ### Documentation This PR does not introduce any new functionality, but it fixes existing functionality that presumably is already documented. * Fix for not respecting custom LoggerFactory client config * Add Custom Logger Factory Test * revert threads used by make in docker-build Co-authored-by: Stepan Mazurov <smazurov@quantummetric.com>
Motivation
I want to use custom logging factory in cpp client
Modifications
#7132 broke custom logger config option. It then was identified in #7503 (and #7502) but not fixed. This PR actually fixes it by checking the right variable name.
Verifying this change
This change is a trivial rework / code cleanup without any test coverage.
Documentation
This PR does not introduce any new functionality, but it fixes existing functionality that presumably is already documented.