You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/12/28 06:59:21 UTC

[GitHub] [pulsar-client-cpp] shibd commented on a diff in pull request #158: The C API supports setting the log level.

shibd commented on code in PR #158:
URL: https://github.com/apache/pulsar-client-cpp/pull/158#discussion_r1058101752


##########
lib/c/c_ClientConfiguration.cc:
##########
@@ -78,7 +78,7 @@ class PulsarCLogger : public pulsar::Logger {
     PulsarCLogger(const std::string &file, pulsar_logger logger, void *ctx)
         : file_(file), logger_(logger), ctx_(ctx) {}
 
-    bool isEnabled(Level level) { return level >= pulsar::Logger::LEVEL_INFO; }
+    bool isEnabled(Level level) { return true; }

Review Comment:
   For C users, We expose a method: `pulsar_logger `.
   
   https://github.com/apache/pulsar-client-cpp/blob/0e86e9f1f8304fd0bbf21185c1c66d0b5ac58482/include/pulsar/c/client_configuration.h#L36-L37
   
   `True` is always returned here in order to let user controls what level of the log is printed in this method.
   
   Such as:
   
   ``` c
   void custom_logger(pulsar_logger_level_t level, const char *file, int line, const char *message,
                 void *ctx) {
       // Control the log level yourself.
       if (level >= pulsar_INFO) {
            printf("[%u] [%s] [%d] [%s] \n", level, file, line, message);
       }
   }
   ```
   
   This approach avoids the need to expose additional interfaces to set the log level.



-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org