Skip to content

Commit

Permalink
Rebase cleanup.
Browse files Browse the repository at this point in the history
Clang-tidy.
Clang-format.
  • Loading branch information
jake-at-work committed Jan 12, 2021
1 parent 3d70902 commit 8c6f7bb
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 66 deletions.
3 changes: 1 addition & 2 deletions cppcache/src/Log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,7 @@ void Log::logInternal(LogLevel level, const std::string& msg) {
removeOldestRolledLogFile();
}

if ((numChars = fprintf(g_log, "%s%s\n", buf.c_str(), msg.c_str())) ==
0 ||
if (fprintf(g_log, "%s%s\n", buf.c_str(), msg.c_str()) == 0 ||
ferror(g_log)) {
// Let's continue without throwing the exception. It should not cause
// process to terminate
Expand Down
13 changes: 8 additions & 5 deletions cppcache/src/Utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,9 @@ class APACHE_GEODE_EXPORT Utils {
* Convert the byte array to a string as "%d %d ...".
* <code>maxLength</code> as zero implies no limit.
*/
static std::string convertBytesToString(const uint8_t* bytes, size_t length,
size_t maxLength = _GEODE_LOG_MESSAGE_LIMIT);
static std::string convertBytesToString(
const uint8_t* bytes, size_t length,
size_t maxLength = _GEODE_LOG_MESSAGE_LIMIT);

/**
* lib should be in the form originally required by ACE_DLL, typically just
Expand All @@ -181,15 +182,17 @@ class APACHE_GEODE_EXPORT Utils {
* Convert the byte array to a string as "%d %d ...".
* <code>maxLength</code> as zero implies no limit.
*/
static std::string convertBytesToString(const int8_t* bytes, size_t length,
size_t maxLength = _GEODE_LOG_MESSAGE_LIMIT);
static std::string convertBytesToString(
const int8_t* bytes, size_t length,
size_t maxLength = _GEODE_LOG_MESSAGE_LIMIT);

/**
* Convert the byte array to a string as "%d %d ...".
* <code>maxLength</code> as zero implies no limit.
*/
inline static std::string convertBytesToString(
const char* bytes, size_t length, size_t maxLength = _GEODE_LOG_MESSAGE_LIMIT) {
const char* bytes, size_t length,
size_t maxLength = _GEODE_LOG_MESSAGE_LIMIT) {
return convertBytesToString(reinterpret_cast<const uint8_t*>(bytes), length,
maxLength);
}
Expand Down
126 changes: 71 additions & 55 deletions cppcache/src/util/Log.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,60 +219,76 @@ class APACHE_GEODE_EXPORT Log {
} // namespace geode
} // namespace apache

#define LOGERROR(...) \
if (::apache::geode::client::Log::enabled( \
apache::geode::client::LogLevel::Error)) { \
::apache::geode::client::Log::log( \
::apache::geode::client::LogLevel::Error, __VA_ARGS__); \
}

#define LOGWARN(...) \
if (::apache::geode::client::Log::enabled( \
apache::geode::client::LogLevel::Warning)) { \
::apache::geode::client::Log::log( \
::apache::geode::client::LogLevel::Warning, __VA_ARGS__); \
}

#define LOGINFO(...) \
if (::apache::geode::client::Log::enabled( \
apache::geode::client::LogLevel::Info)) { \
::apache::geode::client::Log::log(::apache::geode::client::LogLevel::Info, \
__VA_ARGS__); \
}

#define LOGCONFIG(...) \
if (::apache::geode::client::Log::enabled( \
apache::geode::client::LogLevel::Config)) { \
::apache::geode::client::Log::log( \
::apache::geode::client::LogLevel::Config, __VA_ARGS__); \
}

#define LOGFINE(...) \
if (::apache::geode::client::Log::enabled( \
apache::geode::client::LogLevel::Fine)) { \
::apache::geode::client::Log::log(::apache::geode::client::LogLevel::Fine, \
__VA_ARGS__); \
}

#define LOGFINER(...) \
if (::apache::geode::client::Log::enabled( \
apache::geode::client::LogLevel::Finer)) { \
::apache::geode::client::Log::log( \
::apache::geode::client::LogLevel::Finer, __VA_ARGS__); \
}

#define LOGFINEST(...) \
if (::apache::geode::client::Log::enabled( \
apache::geode::client::LogLevel::Finest)) { \
::apache::geode::client::Log::log( \
::apache::geode::client::LogLevel::Finest, __VA_ARGS__); \
}

#define LOGDEBUG(...) \
if (::apache::geode::client::Log::enabled( \
apache::geode::client::LogLevel::Debug)) { \
::apache::geode::client::Log::log( \
::apache::geode::client::LogLevel::Debug, __VA_ARGS__); \
}
#define LOGERROR(...) \
do { \
if (::apache::geode::client::Log::enabled( \
apache::geode::client::LogLevel::Error)) { \
::apache::geode::client::Log::log( \
::apache::geode::client::LogLevel::Error, __VA_ARGS__); \
} \
} while (false)

#define LOGWARN(...) \
do { \
if (::apache::geode::client::Log::enabled( \
apache::geode::client::LogLevel::Warning)) { \
::apache::geode::client::Log::log( \
::apache::geode::client::LogLevel::Warning, __VA_ARGS__); \
} \
} while (false)

#define LOGINFO(...) \
do { \
if (::apache::geode::client::Log::enabled( \
apache::geode::client::LogLevel::Info)) { \
::apache::geode::client::Log::log( \
::apache::geode::client::LogLevel::Info, __VA_ARGS__); \
} \
} while (false)

#define LOGCONFIG(...) \
do { \
if (::apache::geode::client::Log::enabled( \
apache::geode::client::LogLevel::Config)) { \
::apache::geode::client::Log::log( \
::apache::geode::client::LogLevel::Config, __VA_ARGS__); \
} \
} while (false)

#define LOGFINE(...) \
do { \
if (::apache::geode::client::Log::enabled( \
apache::geode::client::LogLevel::Fine)) { \
::apache::geode::client::Log::log( \
::apache::geode::client::LogLevel::Fine, __VA_ARGS__); \
} \
} while (false)

#define LOGFINER(...) \
do { \
if (::apache::geode::client::Log::enabled( \
apache::geode::client::LogLevel::Finer)) { \
::apache::geode::client::Log::log( \
::apache::geode::client::LogLevel::Finer, __VA_ARGS__); \
} \
} while (false)

#define LOGFINEST(...) \
do { \
if (::apache::geode::client::Log::enabled( \
apache::geode::client::LogLevel::Finest)) { \
::apache::geode::client::Log::log( \
::apache::geode::client::LogLevel::Finest, __VA_ARGS__); \
} \
} while (false)

#define LOGDEBUG(...) \
do { \
if (::apache::geode::client::Log::enabled( \
apache::geode::client::LogLevel::Debug)) { \
::apache::geode::client::Log::log( \
::apache::geode::client::LogLevel::Debug, __VA_ARGS__); \
} \
} while (false)

#endif // GEODE_LOG_H_
7 changes: 3 additions & 4 deletions cppcache/test/LoggingTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ class LoggingTest : public testing::Test {
}
}

virtual void SetUp() { scrubTestLogFiles(); }
void SetUp() override { scrubTestLogFiles(); }

virtual void TearDown() { scrubTestLogFiles(); }
void TearDown() override { scrubTestLogFiles(); }

public:
static void writeRolledLogFile(const boost::filesystem::path& logdir,
Expand All @@ -109,13 +109,12 @@ class LoggingTest : public testing::Test {

static int numOfLinesInFile(const char* fname) {
char line[2048];
char* read;
int ln_cnt = 0;
FILE* fp = fopen(fname, "r");
if (fp == nullptr) {
return 0;
}
while (!!(read = fgets(line, sizeof line, fp))) {
while (!!(fgets(line, sizeof line, fp))) {
++ln_cnt;
}

Expand Down

0 comments on commit 8c6f7bb

Please sign in to comment.