-
Notifications
You must be signed in to change notification settings - Fork 182
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
[logging] API change for ecal logging #1853
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
/** | ||
* @brief Log a message (with current log level). | ||
* | ||
* @param msg_ The log message string. | ||
**/ | ||
ECALC_API void eCAL_Logging_Log(const char* const msg_); | ||
ECALC_API void eCAL_Logging_Log(enum eCAL_Logging_eLogLevel level_, const char* const msg_); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: parameter 'msg_' is const-qualified in the function declaration; const-qualification of parameters only has an effect in function definitions [readability-avoid-const-params-in-decls]
ECALC_API void eCAL_Logging_Log(enum eCAL_Logging_eLogLevel level_, const char* const msg_); | |
ECALC_API void eCAL_Logging_Log(enum eCAL_Logging_eLogLevel level_, const char* msg_); |
@@ -29,19 +29,9 @@ | |||
|
|||
extern "C" | |||
{ | |||
ECALC_API void eCAL_Logging_SetLogLevel(enum eCAL_Logging_eLogLevel level_) | |||
ECALC_API void eCAL_Logging_Log(enum eCAL_Logging_eLogLevel level_, const char* const msg_) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "ECALC_API" is directly included [misc-include-cleaner]
ecal/core/src/cimpl/ecal_log_cimpl.cpp:27:
- #include "ecal_common_cimpl.h"
+ #include "ecal/ecal_os.h"
+ #include "ecal_common_cimpl.h"
@@ -29,19 +29,9 @@ | |||
|
|||
extern "C" | |||
{ | |||
ECALC_API void eCAL_Logging_SetLogLevel(enum eCAL_Logging_eLogLevel level_) | |||
ECALC_API void eCAL_Logging_Log(enum eCAL_Logging_eLogLevel level_, const char* const msg_) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "eCAL_Logging_eLogLevel" is directly included [misc-include-cleaner]
ecal/core/src/cimpl/ecal_log_cimpl.cpp:27:
- #include "ecal_common_cimpl.h"
+ #include "ecal/ecal_log_level.h"
+ #include "ecal_common_cimpl.h"
ECALC_API void eCAL_Logging_Log(const char* const msg_) | ||
{ | ||
eCAL::Logging::Log(msg_); | ||
eCAL::Logging::Log(level_, msg_); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "eCAL::Logging::Log" is directly included [misc-include-cleaner]
ecal/core/src/cimpl/ecal_log_cimpl.cpp:27:
- #include "ecal_common_cimpl.h"
+ #include "ecal/ecal_log.h"
+ #include "ecal_common_cimpl.h"
/** | ||
* @brief Log a message. | ||
* | ||
* @param msg_ The log message string. | ||
**/ | ||
void Log(const std::string& msg_) | ||
void Log(eCAL_Logging_eLogLevel level_, const std::string& msg_) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "eCAL_Logging_eLogLevel" is directly included [misc-include-cleaner]
ecal/core/src/logging/ecal_log.cpp:26:
- #include "ecal_log_provider.h"
+ #include "ecal/ecal_log_level.h"
+ #include "ecal_log_provider.h"
@@ -78,7 +78,7 @@ | |||
msgs = 0; | |||
bytes = 0; | |||
|
|||
eCAL::Logging::Log(out.str()); | |||
eCAL::Logging::Log(log_level_info, out.str()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "log_level_info" is directly included [misc-include-cleaner]
ecal/samples/cpp/benchmarks/counter_snd/src/counter_snd.cpp:19:
- #include <ecal/ecal.h>
+ #include "ecal/ecal_log_level.h"
+ #include <ecal/ecal.h>
@@ -98,7 +98,7 @@ int main(int argc, char **argv) | |||
out << "Messages/s: " << (unsigned int)(msgs / diff_time.count()) << std::endl; | |||
out << "Latency (us): " << (diff_time.count() * 1e6) / (double)msgs << std::endl; | |||
std::cout << out.str() << std::endl; | |||
eCAL::Logging::Log(out.str()); | |||
eCAL::Logging::Log(log_level_info, out.str()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "eCAL::Logging::Log" is directly included [misc-include-cleaner]
ecal/samples/cpp/benchmarks/performance_snd/src/performance_snd.cpp:27:
+ #include "ecal/ecal_log.h"
@@ -98,7 +98,7 @@ | |||
out << "Messages/s: " << (unsigned int)(msgs / diff_time.count()) << std::endl; | |||
out << "Latency (us): " << (diff_time.count() * 1e6) / (double)msgs << std::endl; | |||
std::cout << out.str() << std::endl; | |||
eCAL::Logging::Log(out.str()); | |||
eCAL::Logging::Log(log_level_info, out.str()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "log_level_info" is directly included [misc-include-cleaner]
ecal/samples/cpp/benchmarks/performance_snd/src/performance_snd.cpp:27:
+ #include "ecal/ecal_log_level.h"
lang/python/core/src/ecal_clang.cpp
Outdated
{ | ||
eCAL::Logging::Log(message_); | ||
eCAL::Logging::Log(eCAL_Logging_eLogLevel(level_), message_); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "eCAL::Logging::Log" is directly included [misc-include-cleaner]
lang/python/core/src/ecal_clang.cpp:27:
+ #include "ecal/ecal_log.h"
lang/python/core/src/ecal_clang.cpp
Outdated
{ | ||
eCAL::Logging::Log(message_); | ||
eCAL::Logging::Log(eCAL_Logging_eLogLevel(level_), message_); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "eCAL_Logging_eLogLevel" is directly included [misc-include-cleaner]
lang/python/core/src/ecal_clang.cpp:27:
+ #include "ecal/ecal_log_level.h"
lang/python/core/ecal/core/core.py
Outdated
@@ -148,7 +148,8 @@ def log_setlevel(level): | |||
:type level: int | |||
|
|||
""" | |||
return _ecal.log_setlevel(level) | |||
print("[WARNING] 'log_setlevel(int)' is deprecated. All logs will have the log level 'all' until the new API is introduced.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implement set log level function using global level state variable in ecal python c++ wrapper as intermediate solution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finally :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
/****************************************/ | ||
/* log_message */ | ||
/****************************************/ | ||
void log_message(const char* message_) | ||
void log_message(const eCAL_Logging_eLogLevel& log_level_, const char* message_) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "eCAL_Logging_eLogLevel" is directly included [misc-include-cleaner]
lang/python/core/src/ecal_clang.cpp:27:
+ #include "ecal/ecal_log_level.h"
{ | ||
eCAL::Logging::Log(message_); | ||
eCAL::Logging::Log(log_level_, message_); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "eCAL::Logging::Log" is directly included [misc-include-cleaner]
lang/python/core/src/ecal_clang.cpp:27:
+ #include "ecal/ecal_log.h"
/** | ||
* @brief Log a message (with current log level). | ||
* | ||
* @param message_ The log message string. | ||
**/ | ||
void log_message(const char* message_); | ||
void log_message(const eCAL_Logging_eLogLevel& level_, const char* message_); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "eCAL_Logging_eLogLevel" is directly included [misc-include-cleaner]
lang/python/core/src/ecal_clang.h:26:
- #include <ecal/ecalc.h>
+ #include "ecal/ecal_log_level.h"
+ #include <ecal/ecalc.h>
@@ -64,6 +64,8 @@ PySubscriberCallbackMapT g_subscriber_pycallback_map; | |||
PyServerMethodCallbackMapT g_server_method_pycallback_map; | |||
PyClientCallbackMapT g_client_pycallback_map; | |||
|
|||
eCAL_Logging_eLogLevel g_python_log_level = log_level_info; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "eCAL_Logging_eLogLevel" is directly included [misc-include-cleaner]
lang/python/core/src/ecal_wrap.cxx:22:
- #define PY_SSIZE_T_CLEAN
+ #include "ecal/ecal_log_level.h"
+ #define PY_SSIZE_T_CLEAN
@@ -64,6 +64,8 @@ | |||
PyServerMethodCallbackMapT g_server_method_pycallback_map; | |||
PyClientCallbackMapT g_client_pycallback_map; | |||
|
|||
eCAL_Logging_eLogLevel g_python_log_level = log_level_info; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "log_level_info" is directly included [misc-include-cleaner]
eCAL_Logging_eLogLevel g_python_log_level = log_level_info;
^
@@ -64,6 +64,8 @@ | |||
PyServerMethodCallbackMapT g_server_method_pycallback_map; | |||
PyClientCallbackMapT g_client_pycallback_map; | |||
|
|||
eCAL_Logging_eLogLevel g_python_log_level = log_level_info; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: variable 'g_python_log_level' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]
eCAL_Logging_eLogLevel g_python_log_level = log_level_info;
^
Description
Removed setter and getter for loglevel. This means, changing of log level is only possible via configuration before initialization.
Removed eCAL::Logging::Log(const std::string&) signature. User now always has to specify the log level to write with.
Deprecated set_loglevel in Python bindings. Python will now always log in "log_level_all" until new logging and API will be introduced.