From 312528135536cc74d5779459a62bd52f26e344fe Mon Sep 17 00:00:00 2001 From: ihsan demir Date: Mon, 25 Apr 2016 00:06:15 +0300 Subject: [PATCH 1/2] Correct the log for date the same as Java log. --- CMakeLists.txt | 11 ++--------- hazelcast/include/hazelcast/util/Util.h | 3 --- .../hazelcast/client/spi/LifecycleService.cpp | 18 +++++++++++++++--- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a257dcd02e..fd30df3ff6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,20 +29,13 @@ add_definitions(-DHAZELCAST_VERSION="${HZ_VERSION}") execute_process(COMMAND git show -s --format="%cd" --date=short OUTPUT_VARIABLE HAZELCAST_GIT_COMMIT_DATE) string(STRIP "${HAZELCAST_GIT_COMMIT_DATE}" HAZELCAST_GIT_COMMIT_DATE) -if ("x${HAZELCAST_GIT_COMMIT_DATE}" MATCHES "x") - SET(HAZELCAST_GIT_COMMIT_DATE "NOT_FOUND") -endif() message(STATUS "HAZELCAST_GIT_COMMIT_DATE = ${HAZELCAST_GIT_COMMIT_DATE}" ) -add_definitions(-DHAZELCAST_GIT_COMMIT_DATE="${HAZELCAST_GIT_COMMIT_DATE}") +add_definitions(-DHAZELCAST_GIT_COMMIT_DATE=${HAZELCAST_GIT_COMMIT_DATE}) execute_process(COMMAND git show -s --format="%h" OUTPUT_VARIABLE HAZELCAST_GIT_COMMIT_ID) string(STRIP "${HAZELCAST_GIT_COMMIT_ID}" HAZELCAST_GIT_COMMIT_ID) -if ("x${HAZELCAST_GIT_COMMIT_ID}" MATCHES "x") - SET(HAZELCAST_GIT_COMMIT_ID "NOT_FOUND") -endif() message(STATUS "HAZELCAST_GIT_COMMIT_ID = ${HAZELCAST_GIT_COMMIT_ID}" ) -add_definitions(-DHAZELCAST_GIT_COMMIT_ID="${HAZELCAST_GIT_COMMIT_ID}") - +add_definitions(-DHAZELCAST_GIT_COMMIT_ID=${HAZELCAST_GIT_COMMIT_ID}) message(STATUS "Preparing hazelcast client ..... ") diff --git a/hazelcast/include/hazelcast/util/Util.h b/hazelcast/include/hazelcast/util/Util.h index 8366663d7e..5a1b3b3ac3 100644 --- a/hazelcast/include/hazelcast/util/Util.h +++ b/hazelcast/include/hazelcast/util/Util.h @@ -22,9 +22,6 @@ #include "hazelcast/util/HazelcastDll.h" #include -#define HAZELCAST_STRINGIZE(X) HZ_STRINGIZE(X) -#define HZ_STRINGIZE(X) #X - namespace hazelcast { namespace util { diff --git a/hazelcast/src/hazelcast/client/spi/LifecycleService.cpp b/hazelcast/src/hazelcast/client/spi/LifecycleService.cpp index 403f845b11..7125151702 100644 --- a/hazelcast/src/hazelcast/client/spi/LifecycleService.cpp +++ b/hazelcast/src/hazelcast/client/spi/LifecycleService.cpp @@ -26,6 +26,14 @@ #include "hazelcast/client/connection/ConnectionManager.h" #include "hazelcast/client/LifecycleListener.h" +#ifndef HAZELCAST_GIT_COMMIT_DATE +#define HAZELCAST_GIT_COMMIT_DATE "NOT_FOUND" +#endif + +#ifndef HAZELCAST_GIT_COMMIT_ID +#define HAZELCAST_GIT_COMMIT_ID "NOT_FOUND" +#endif + namespace hazelcast { namespace client { namespace spi { @@ -89,10 +97,14 @@ namespace hazelcast { switch (lifecycleEvent.getState()) { case LifecycleEvent::STARTING : { + // convert the date string from 2016-04-20 to 20160420 + std::string date(HAZELCAST_GIT_COMMIT_DATE); + if (date != "NOT_FOUND") { + date.erase(4, 1); + date.erase(6, 1); + } char msg[100]; - util::snprintf(msg, 100, "(%s:%s) LifecycleService::LifecycleEvent STARTING", - HAZELCAST_STRINGIZE(HAZELCAST_GIT_COMMIT_DATE), - HAZELCAST_STRINGIZE(HAZELCAST_GIT_COMMIT_ID)); + util::snprintf(msg, 100, "(%s:%s) LifecycleService::LifecycleEvent STARTING", date.c_str(), HAZELCAST_GIT_COMMIT_ID); logger.info(msg); break; } From 1a76b95ad35c29c6d3cf8fa84fa2b1dce8171f62 Mon Sep 17 00:00:00 2001 From: ihsan demir Date: Mon, 25 Apr 2016 10:30:39 +0300 Subject: [PATCH 2/2] Added handling for git show command execution failures. --- CMakeLists.txt | 26 ++++++++++++++++--- .../hazelcast/client/spi/LifecycleService.cpp | 8 ------ 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fd30df3ff6..6741c7769b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,13 +27,31 @@ INCLUDE(TestBigEndian) SET(HZ_VERSION 3.7-SNAPSHOT) add_definitions(-DHAZELCAST_VERSION="${HZ_VERSION}") -execute_process(COMMAND git show -s --format="%cd" --date=short OUTPUT_VARIABLE HAZELCAST_GIT_COMMIT_DATE) -string(STRIP "${HAZELCAST_GIT_COMMIT_DATE}" HAZELCAST_GIT_COMMIT_DATE) +execute_process(COMMAND git show -s --format="%cd" --date=short OUTPUT_VARIABLE HAZELCAST_GIT_COMMIT_DATE RESULT_VARIABLE GIT_DATE_RESULT) +if (NOT (${GIT_DATE_RESULT} EQUAL 0)) + message(WARNING "Could not execute command git show for obtaining the git commit date. Process exit result:${GIT_DATE_RESULT}") + set(HAZELCAST_GIT_COMMIT_DATE "NOT_FOUND") +else() + string(STRIP "${HAZELCAST_GIT_COMMIT_DATE}" HAZELCAST_GIT_COMMIT_DATE) + if ("${HAZELCAST_GIT_COMMIT_DATE}" STREQUAL "") + message(WARNING "git show command returned empty commit date.") + set(HAZELCAST_GIT_COMMIT_DATE "NOT_FOUND") + endif() +endif () message(STATUS "HAZELCAST_GIT_COMMIT_DATE = ${HAZELCAST_GIT_COMMIT_DATE}" ) add_definitions(-DHAZELCAST_GIT_COMMIT_DATE=${HAZELCAST_GIT_COMMIT_DATE}) -execute_process(COMMAND git show -s --format="%h" OUTPUT_VARIABLE HAZELCAST_GIT_COMMIT_ID) -string(STRIP "${HAZELCAST_GIT_COMMIT_ID}" HAZELCAST_GIT_COMMIT_ID) +execute_process(COMMAND git show -s --format="%h" OUTPUT_VARIABLE HAZELCAST_GIT_COMMIT_ID RESULT_VARIABLE GIT_COMMIT_ID_RESULT) +if (NOT (${GIT_COMMIT_ID_RESULT} EQUAL 0)) + message(WARNING "Could not execute command git show for obtaining the git commit id. Process exit result:${GIT_DATE_RESULT}") + set(HAZELCAST_GIT_COMMIT_ID "NOT_FOUND") +else() + string(STRIP "${HAZELCAST_GIT_COMMIT_ID}" HAZELCAST_GIT_COMMIT_ID) + if ("${HAZELCAST_GIT_COMMIT_ID}" STREQUAL "") + message(WARNING "git show command returned empty commit id.") + set(HAZELCAST_GIT_COMMIT_ID "NOT_FOUND") + endif() +endif () message(STATUS "HAZELCAST_GIT_COMMIT_ID = ${HAZELCAST_GIT_COMMIT_ID}" ) add_definitions(-DHAZELCAST_GIT_COMMIT_ID=${HAZELCAST_GIT_COMMIT_ID}) diff --git a/hazelcast/src/hazelcast/client/spi/LifecycleService.cpp b/hazelcast/src/hazelcast/client/spi/LifecycleService.cpp index 7125151702..d4894cc998 100644 --- a/hazelcast/src/hazelcast/client/spi/LifecycleService.cpp +++ b/hazelcast/src/hazelcast/client/spi/LifecycleService.cpp @@ -26,14 +26,6 @@ #include "hazelcast/client/connection/ConnectionManager.h" #include "hazelcast/client/LifecycleListener.h" -#ifndef HAZELCAST_GIT_COMMIT_DATE -#define HAZELCAST_GIT_COMMIT_DATE "NOT_FOUND" -#endif - -#ifndef HAZELCAST_GIT_COMMIT_ID -#define HAZELCAST_GIT_COMMIT_ID "NOT_FOUND" -#endif - namespace hazelcast { namespace client { namespace spi {