Skip to content

Commit

Permalink
Fixed static dynamic allocation for log level. Added compile target d…
Browse files Browse the repository at this point in the history
…efinition to core.
  • Loading branch information
JonathanHenson committed Feb 18, 2016
1 parent 68396d6 commit 7f4b08a
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 27 deletions.
10 changes: 0 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,6 @@ else()
message(STATUS "Dynamic linking enabled")
endif()

# If building shared libraries, custom memory management enabled is the default, otherwise regular memory management is the default.
# We make custom memory management the default on shared library builds because it is safer and much more difficult to accidentally
# allocate in one DLLs heap while freeing in another (which will lead to runtime crashes)
if(("${CUSTOM_MEMORY_MANAGEMENT}" STREQUAL "1") OR (BUILD_SHARED_LIBS AND NOT ("${CUSTOM_MEMORY_MANAGEMENT}" STREQUAL "0")))
add_definitions(-DAWS_CUSTOM_MEMORY_MANAGEMENT)
message(STATUS "Custom memory management enabled; stl objects now using custom allocators")
else()
message(STATUS "Custom memory management disabled")
endif()

# Http client control
# After this section runs, client availability is technically platform-independent (ie we use the client #defines rather than a mess of platform #defines)
# on Windows, set CURL_DIR to a valid curl install directory in order to enable the curl client
Expand Down
10 changes: 10 additions & 0 deletions aws-cpp-sdk-core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,16 @@ target_include_directories(aws-cpp-sdk-core PUBLIC
$<INSTALL_INTERFACE:include>)
target_link_libraries(aws-cpp-sdk-core ${PLATFORM_DEP_LIBS} ${CRYPTO_LIBS} ${CLIENT_LIBS})

# If building shared libraries, custom memory management enabled is the default, otherwise regular memory management is the default.
# We make custom memory management the default on shared library builds because it is safer and much more difficult to accidentally
# allocate in one DLLs heap while freeing in another (which will lead to runtime crashes)
if(("${CUSTOM_MEMORY_MANAGEMENT}" STREQUAL "1") OR (BUILD_SHARED_LIBS AND NOT ("${CUSTOM_MEMORY_MANAGEMENT}" STREQUAL "0")))
target_compile_definitions(aws-cpp-sdk-core PUBLIC -DAWS_CUSTOM_MEMORY_MANAGEMENT)
message(STATUS "Custom memory management enabled; stl objects now using custom allocators")
else()
message(STATUS "Custom memory management disabled")
endif()

install (TARGETS aws-cpp-sdk-core ARCHIVE DESTINATION ${ARCHIVE_DIRECTORY}/${SDK_INSTALL_BINARY_PREFIX}/\${CMAKE_INSTALL_CONFIG_NAME}
LIBRARY DESTINATION lib/${SDK_INSTALL_BINARY_PREFIX}/\${CMAKE_INSTALL_CONFIG_NAME}
RUNTIME DESTINATION bin/${SDK_INSTALL_BINARY_PREFIX}/\${CMAKE_INSTALL_CONFIG_NAME})
Expand Down
2 changes: 1 addition & 1 deletion aws-cpp-sdk-core/include/aws/core/VersionConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
* permissions and limitations under the License.
*/

#define AWS_SDK_VERSION_STRING "0.9.6-24-gfd5d52a"
#define AWS_SDK_VERSION_STRING "0.9.6-25-g68396d6"
35 changes: 19 additions & 16 deletions aws-cpp-sdk-core/source/utils/logging/LogLevel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,10 @@

#include <aws/core/utils/memory/stl/AWSMap.h>
#include <aws/core/utils/memory/stl/AWSString.h>
#include <cassert>

using namespace Aws::Utils::Logging;

static Aws::Map<LogLevel, Aws::String> logLevelNameMap =
{
{ LogLevel::Fatal, "FATAL" },
{ LogLevel::Error, "ERROR" },
{ LogLevel::Warn, "WARN" },
{ LogLevel::Info, "INFO" },
{ LogLevel::Debug, "DEBUG" },
{ LogLevel::Trace, "TRACE" } };

namespace Aws
{
namespace Utils
Expand All @@ -38,13 +30,24 @@ namespace Logging

Aws::String GetLogLevelName(LogLevel logLevel)
{
auto iter = logLevelNameMap.find(logLevel);
if(iter == logLevelNameMap.cend())
{
return Aws::String("");
}

return iter->second;
switch (logLevel)
{
case LogLevel::Fatal:
return "FATAL";
case LogLevel::Error:
return "ERROR";
case LogLevel::Warn:
return "WARN";
case LogLevel::Info:
return "INFO";
case LogLevel::Debug:
return "DEBUG";
case LogLevel::Trace:
return "TRACE";
default:
assert(0);
return "";
}
}

} // namespace Logging
Expand Down

0 comments on commit 7f4b08a

Please sign in to comment.