You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@celix.apache.org by "xuzhenbao (via GitHub)" <gi...@apache.org> on 2023/03/30 08:59:36 UTC

[GitHub] [celix] xuzhenbao opened a new issue, #503: How to improve the log helper of libdfi

xuzhenbao opened a new issue, #503:
URL: https://github.com/apache/celix/issues/503

   https://github.com/apache/celix/blob/master/libs/dfi/include/dfi_log_util.h
   https://github.com/apache/celix/blob/master/bundles/remote_services/remote_service_admin_dfi/src/remote_service_admin_dfi.c#l199-l204
   
   If there are multiple bundles using the libdfi,  we can not call <dif_cmp>_logSetup(eg:jsonRpc_logSetup) in each bundle. 
   
   


-- 
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: dev-unsubscribe@celix.apache.org.apache.org

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


[GitHub] [celix] PengZheng commented on issue #503: How to improve the log helper of libdfi

Posted by "PengZheng (via GitHub)" <gi...@apache.org>.
PengZheng commented on issue #503:
URL: https://github.com/apache/celix/issues/503#issuecomment-1490007686

   Yes, we need a general design for logging for library without bundle context.


-- 
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: dev-unsubscribe@celix.apache.org

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


Re: [I] How to improve the log helper of libdfi (celix)

Posted by "xuzhenbao (via GitHub)" <gi...@apache.org>.
xuzhenbao closed issue #503: How to improve the log helper of libdfi
URL: https://github.com/apache/celix/issues/503


-- 
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: dev-unsubscribe@celix.apache.org

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


[GitHub] [celix] PengZheng commented on issue #503: How to improve the log helper of libdfi

Posted by "PengZheng (via GitHub)" <gi...@apache.org>.
PengZheng commented on issue #503:
URL: https://github.com/apache/celix/issues/503#issuecomment-1490127335

   OpenSSL's error queue [ERR](https://www.openssl.org/docs/man3.1/man3/ERR_get_error.html) like another plausible solution: it collect logging in each level of the call stack. At the top level (i.e. the calling thread's task function), we have access to a bundle context, therefore can fetch stacked logging messages and feed them into the log helper.


-- 
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: dev-unsubscribe@celix.apache.org

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


[GitHub] [celix] PengZheng commented on issue #503: How to improve the log helper of libdfi

Posted by "PengZheng (via GitHub)" <gi...@apache.org>.
PengZheng commented on issue #503:
URL: https://github.com/apache/celix/issues/503#issuecomment-1495288639

   > I assume this is done using thread local storage?
   
   Yes. 
   
   It is a fair complex subsystem and is not easy to extend (i.e. add new error codes) outside of OpenSSL in its current form.
   See https://github.com/openssl/openssl/tree/master/crypto/err
   
   


-- 
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: dev-unsubscribe@celix.apache.org

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


[GitHub] [celix] PengZheng commented on issue #503: How to improve the log helper of libdfi

Posted by "PengZheng (via GitHub)" <gi...@apache.org>.
PengZheng commented on issue #503:
URL: https://github.com/apache/celix/issues/503#issuecomment-1490043541

   One way of solving this is to make libdfi a static library, thus we have separate copies of logger for each bundle.
   We may need to solve #442 to mitigate code bloat caused by multiple copies of libdfi.
   
   But this is not a general solution. What about a shared library without bundle context?


-- 
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: dev-unsubscribe@celix.apache.org

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


Re: [I] How to improve the log helper of libdfi (celix)

Posted by "xuzhenbao (via GitHub)" <gi...@apache.org>.
xuzhenbao commented on issue #503:
URL: https://github.com/apache/celix/issues/503#issuecomment-1539266517

   Now,we have celix_err, but how do we feed its error messages to the logHelper?
   How about do it in function `celix_logHelper_vlogDetails`, as follows:
   ~~~
   void celix_logHelper_vlogDetails(celix_log_helper_t* logHelper, celix_log_level_e level, const char* file, const char* function, int line, const char *format, va_list formatArgs) {
       if (level == CELIX_LOG_LEVEL_DISABLED) {
           //silently ignore
           celix_err_resetErrors();
           return;
       }
       if (level >= logHelper->activeLogLevel) {
           celixThreadMutex_lock(&logHelper->mutex);
           celix_log_service_t* ls = logHelper->logService;
           if (ls != NULL) {
               ls->vlog(ls->handle, level, format, formatArgs);
               for (const char *errMsg = celix_err_popLastError(); errMsg != NULL; errMsg = celix_err_popLastError()) {
                   ls->log(ls->handle, level, "%s", errMsg);
               }
           } else {
               //falling back on stdout/stderr
               celix_logUtils_vLogToStdout(logHelper->logServiceName, level, format, formatArgs);
               for (const char *errMsg = celix_err_popLastError(); errMsg != NULL; errMsg = celix_err_popLastError()) {
                   celix_logUtils_logToStdout(logHelper->logServiceName, level, "%s", errMsg);
               }
           }
           logHelper->logCount += 1;
           celixThreadMutex_unlock(&logHelper->mutex);
       }
       celix_err_resetErrors();
   }
   ~~~


-- 
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: dev-unsubscribe@celix.apache.org

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


[GitHub] [celix] pnoltes commented on issue #503: How to improve the log helper of libdfi

Posted by "pnoltes (via GitHub)" <gi...@apache.org>.
pnoltes commented on issue #503:
URL: https://github.com/apache/celix/issues/503#issuecomment-1494575195

   An per thread error queue sound like a good solution for non-celix-framework libs.
   
   I am curious has the memory cleanup can be done, given the OpenSSL's error queue documentation: "An application MUST NOT free the *data pointer (or any other pointers returned by these functions) with OPENSSL_free() as freeing is handled automatically by the error library." 
   
   I assume this is done using thread local storage? 


-- 
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: dev-unsubscribe@celix.apache.org

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


Re: [I] How to improve the log helper of libdfi (celix)

Posted by "PengZheng (via GitHub)" <gi...@apache.org>.
PengZheng commented on issue #503:
URL: https://github.com/apache/celix/issues/503#issuecomment-1540160676

   I see several issues with this prototype:
   
   1. Weird semantics. Why  trying to log a trace message will dump the err?
   2. Inefficiency. Try `celix_err_popLastError` will allocation the err per-thread-storage, even if there is no user of err in this thread.
   3. Reduced usefulness of stacked error message. The current implementation output err messages one by one, which will be interleaved by other log messages in multi-threaded application.


-- 
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: dev-unsubscribe@celix.apache.org

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


[GitHub] [celix] xuzhenbao commented on issue #503: How to improve the log helper of libdfi

Posted by "xuzhenbao (via GitHub)" <gi...@apache.org>.
xuzhenbao commented on issue #503:
URL: https://github.com/apache/celix/issues/503#issuecomment-1490008192

   Other libraries(like "utils") use `fprintf` for logging. Maybe we should design a logging style that works for the base library.


-- 
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: dev-unsubscribe@celix.apache.org

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