Skip to content

Commit

Permalink
client: use KUDU_LOG(INFO) instead of KUDU_LOG(KUDU_INFO)
Browse files Browse the repository at this point in the history
This changes around the preprocessor definitions so that we can use
KUDU_LOG(level) directly instead of having to prefix each level
with KUDU_.

Change-Id: I46d48d249e9b0cc2d0832207bebd58efaeb21459
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/6888
Reviewed-by: Adar Dembo <[email protected]>
Tested-by: jenkins
  • Loading branch information
toddlipcon committed Jun 10, 2015
1 parent 7fc29d2 commit d4b1c52
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 28 deletions.
32 changes: 16 additions & 16 deletions src/kudu/client/samples/sample.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ static Status AlterTable(const shared_ptr<KuduClient>& client,
}

static void StatusCB(void* unused, const Status& status) {
KUDU_LOG(KUDU_INFO) << "Asynchronous flush finished with status: "
KUDU_LOG(INFO) << "Asynchronous flush finished with status: "
<< status.ToString();
}

Expand Down Expand Up @@ -196,15 +196,15 @@ static void LogCb(void* unused,
const struct ::tm* time,
const char* message,
size_t message_len) {
KUDU_LOG(KUDU_INFO) << "Received log message from Kudu client library";
KUDU_LOG(KUDU_INFO) << " Severity: " << severity;
KUDU_LOG(KUDU_INFO) << " Filename: " << filename;
KUDU_LOG(KUDU_INFO) << " Line number: " << line_number;
KUDU_LOG(INFO) << "Received log message from Kudu client library";
KUDU_LOG(INFO) << " Severity: " << severity;
KUDU_LOG(INFO) << " Filename: " << filename;
KUDU_LOG(INFO) << " Line number: " << line_number;
char time_buf[32];
// Example: Tue Mar 24 11:46:43 2015.
KUDU_CHECK(strftime(time_buf, sizeof(time_buf), "%a %b %d %T %Y", time));
KUDU_LOG(KUDU_INFO) << " Time: " << time_buf;
KUDU_LOG(KUDU_INFO) << " Message: " << string(message, message_len);
KUDU_LOG(INFO) << " Time: " << time_buf;
KUDU_LOG(INFO) << " Message: " << string(message, message_len);
}

int main(int argc, char* argv[]) {
Expand All @@ -219,44 +219,44 @@ int main(int argc, char* argv[]) {
// Create and connect a client.
shared_ptr<KuduClient> client;
KUDU_CHECK_OK(CreateClient("127.0.0.1", &client));
KUDU_LOG(KUDU_INFO) << "Created a client connection";
KUDU_LOG(INFO) << "Created a client connection";

// Disable the verbose logging.
kudu::client::SetVerboseLogLevel(0);

// Create a schema.
KuduSchema schema(CreateSchema());
KUDU_LOG(KUDU_INFO) << "Created a schema";
KUDU_LOG(INFO) << "Created a schema";

// Create a table with that schema.
bool exists;
KUDU_CHECK_OK(DoesTableExist(client, kTableName, &exists));
if (exists) {
client->DeleteTable(kTableName);
KUDU_LOG(KUDU_INFO) << "Deleting old table before creating new one";
KUDU_LOG(INFO) << "Deleting old table before creating new one";
}
KUDU_CHECK_OK(CreateTable(client, kTableName, schema, 10));
KUDU_LOG(KUDU_INFO) << "Created a table";
KUDU_LOG(INFO) << "Created a table";

// Alter the table.
KUDU_CHECK_OK(AlterTable(client, kTableName));
KUDU_LOG(KUDU_INFO) << "Altered a table";
KUDU_LOG(INFO) << "Altered a table";

// Insert some rows into the table.
shared_ptr<KuduTable> table;
KUDU_CHECK_OK(client->OpenTable(kTableName, &table));
KUDU_CHECK_OK(InsertRows(table, 1000));
KUDU_LOG(KUDU_INFO) << "Inserted some rows into a table";
KUDU_LOG(INFO) << "Inserted some rows into a table";

// Scan some rows.
KUDU_CHECK_OK(ScanRows(table));
KUDU_LOG(KUDU_INFO) << "Scanned some rows out of a table";
KUDU_LOG(INFO) << "Scanned some rows out of a table";

// Delete the table.
KUDU_CHECK_OK(client->DeleteTable(kTableName));
KUDU_LOG(KUDU_INFO) << "Deleted a table";
KUDU_LOG(INFO) << "Deleted a table";

// Done!
KUDU_LOG(KUDU_INFO) << "Done";
KUDU_LOG(INFO) << "Done";
return 0;
}
5 changes: 3 additions & 2 deletions src/kudu/client/stubs.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,11 @@
#define KUDU_DFATAL KUDU_FATAL
#endif // NDEBUG

#define KUDU_LOG(level) kudu::internal_logging::CerrLog(level)
#define KUDU_LOG_INTERNAL(level) kudu::internal_logging::CerrLog(level)
#define KUDU_LOG(level) KUDU_LOG_INTERNAL(KUDU_##level)

#define KUDU_CHECK(condition) \
(condition) ? 0 : KUDU_LOG(KUDU_FATAL) << "Check failed: " #condition " "
(condition) ? 0 : KUDU_LOG(FATAL) << "Check failed: " #condition " "

namespace kudu {

Expand Down
13 changes: 3 additions & 10 deletions src/kudu/util/status.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
#define KUDU_WARN_NOT_OK(to_call, warning_prefix) do { \
::kudu::Status _s = (to_call); \
if (PREDICT_FALSE(!_s.ok())) { \
KUDU_LOG(KUDU_WARNING) << (warning_prefix) << ": " << _s.ToString(); \
KUDU_LOG(WARNING) << (warning_prefix) << ": " << _s.ToString(); \
} \
} while (0);

Expand Down Expand Up @@ -87,16 +87,9 @@
#define CHECK_OK_PREPEND KUDU_CHECK_OK_PREPEND
#define CHECK_OK KUDU_CHECK_OK

// These are all standard glog macros.
//
// LOG(...) needs to be handled differently due to how glog/logging.h does
// token concatenation.
#define KUDU_LOG(level) LOG(level)
// These are standard glog macros.
#define KUDU_LOG LOG
#define KUDU_CHECK CHECK
#define KUDU_INFO INFO
#define KUDU_WARNING WARNING
#define KUDU_ERROR ERROR
#define KUDU_FATAL FATAL
#endif

namespace kudu {
Expand Down

0 comments on commit d4b1c52

Please sign in to comment.