Skip to content

Added OPT_OUTPUTDEBUGSTRING option for GUI debugging (Win) #70

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ option(OPT_SAMPLES "Build the samples" ON)
option(OPT_BUILD_TESTS "Build the tests" OFF)
option(OPT_BUILD_STATIC "Build static libraries for the client" ON)
option(OPT_LOG4CXX "Use log4cxx for logging" ON)
option(OPT_OUTPUTDEBUGSTRING "Use OutputDebugString logging (only Windows, log4cxx preferred)" OFF)

# Use, i.e. don't skip the full RPATH for the build tree
set(CMAKE_SKIP_BUILD_RPATH FALSE)
Expand Down Expand Up @@ -136,6 +137,11 @@ endif()

set(MUJINCLIENT_LINK_DIRS)

set(MUJINCLIENT_OUTPUTDEBUGSTRING 0)
if(OPT_OUTPUTDEBUGSTRING AND MSVC)
set(MUJINCLIENT_OUTPUTDEBUGSTRING 1)
endif()

find_package(PkgConfig)
set(MUJINCLIENT_LOG4CXX 0)
if (OPT_LOG4CXX)
Expand Down
1 change: 1 addition & 0 deletions config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@

// whether log4cxx is to be used
#define MUJINCLIENT_LOG4CXX @MUJINCLIENT_LOG4CXX@
#define MUJINCLIENT_OUTPUTDEBUGSTRING @MUJINCLIENT_OUTPUTDEBUGSTRING@
#define MUJIN_USEZMQ @MUJIN_USEZMQ@

#endif
4 changes: 2 additions & 2 deletions src/controllerclientimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ ControllerClientImpl::ControllerClientImpl(const std::string& usernamepassword,
_charset = itcodepage->second;
}
#endif
MUJIN_LOG_INFO("setting character set to " << _charset);
MUJIN_LOG_INFO(std::string("setting character set to ")+_charset);
_SetupHTTPHeadersJSON();
_SetupHTTPHeadersSTL();
_SetupHTTPHeadersMultipartFormData();
Expand Down Expand Up @@ -1837,7 +1837,7 @@ void ControllerClientImpl::_DeleteDirectoryOnController(const std::string& destu
CURL_PERFORM(_curl);
long http_code = 0;
CURL_INFO_GETTER(_curl, CURLINFO_RESPONSE_CODE, &http_code);
MUJIN_LOG_INFO("response code: " << http_code);
MUJIN_LOG_INFO(str(boost::format("response code: %d")%http_code));
}

size_t ControllerClientImpl::_ReadUploadCallback(void *ptr, size_t size, size_t nmemb, void *stream)
Expand Down
8 changes: 8 additions & 0 deletions src/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@
#define MUJIN_LOG_INFO(msg) LOG4CXX_INFO(logger, msg);
#define MUJIN_LOG_ERROR(msg) LOG4CXX_ERROR(logger, msg);

#elif MUJINCLIENT_OUTPUTDEBUGSTRING

#define MUJIN_LOGGER(name)
#define MUJIN_LOG_VERBOSE(msg) // empty
#define MUJIN_LOG_DEBUG(msg) OutputDebugString(std::string(msg).c_str());
#define MUJIN_LOG_INFO(msg) OutputDebugString(std::string(msg).c_str());
#define MUJIN_LOG_ERROR(msg) OutputDebugString(std::string(msg).c_str());

#else

#define MUJIN_LOGGER(name)
Expand Down
6 changes: 3 additions & 3 deletions src/mujinzmq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ std::string ZmqClient::Call(const std::string& msg, const double timeout, const
ss << "Timed out trying to send request.";
MUJIN_LOG_ERROR(ss.str());
if (msg.length() > 1000) {
MUJIN_LOG_INFO(msg.substr(0,1000) << "...");
MUJIN_LOG_INFO(msg.substr(0,1000)+"...");
} else {
MUJIN_LOG_INFO(msg);
}
Expand Down Expand Up @@ -354,7 +354,7 @@ std::string ZmqClient::Call(const std::string& msg, const double timeout, const
} else {
MUJIN_LOG_INFO("failed to send");
if (msg.length() > 1000) {
MUJIN_LOG_INFO(msg.substr(0,1000) << "...");
MUJIN_LOG_INFO(msg.substr(0,1000)+"...");
} else {
MUJIN_LOG_INFO(msg);
}
Expand All @@ -379,7 +379,7 @@ std::string ZmqClient::Call(const std::string& msg, const double timeout, const
ss << "timed out trying to receive request";
MUJIN_LOG_ERROR(ss.str());
if (msg.length() > 1000) {
MUJIN_LOG_INFO(msg.substr(0,1000) << "...");
MUJIN_LOG_INFO(msg.substr(0,1000)+"...");
} else {
MUJIN_LOG_INFO(msg);
}
Expand Down