From f00547bb7d65d2da142dd3fa3205faf6a7e55984 Mon Sep 17 00:00:00 2001 From: "Adam C. Emerson" Date: Thu, 5 Oct 2017 18:27:37 -0400 Subject: [PATCH] log: Add optional msg parameter to create_entry and test with it The tests should, really, get their time from the same source as the log, and also probably use the same interface to creating entries that other people do. So add an optional message argument and have the tests use that rather than using the new operator directly. Signed-off-by: Adam C. Emerson --- src/log/Log.cc | 4 ++-- src/log/Log.h | 2 +- src/log/test.cc | 26 +++++++++++--------------- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/log/Log.cc b/src/log/Log.cc index bf219d379fa..e8d7ec00e8e 100644 --- a/src/log/Log.cc +++ b/src/log/Log.cc @@ -222,12 +222,12 @@ void Log::submit_entry(Entry *e) } -Entry *Log::create_entry(int level, int subsys) +Entry *Log::create_entry(int level, int subsys, const char* msg) { if (true) { return new Entry(ceph_clock_now(), pthread_self(), - level, subsys); + level, subsys, msg); } else { // kludge for perf testing Entry *e = m_recent.dequeue(); diff --git a/src/log/Log.h b/src/log/Log.h index ce77daabc41..c977ee8e358 100644 --- a/src/log/Log.h +++ b/src/log/Log.h @@ -82,7 +82,7 @@ public: shared_ptr graylog() { return m_graylog; } - Entry *create_entry(int level, int subsys); + Entry *create_entry(int level, int subsys, const char* msg = nullptr); Entry *create_entry(int level, int subsys, size_t* expected_size); void submit_entry(Entry *e); diff --git a/src/log/test.cc b/src/log/test.cc index e11505af456..d423e4125b9 100644 --- a/src/log/test.cc +++ b/src/log/test.cc @@ -29,11 +29,7 @@ TEST(Log, Simple) int sys = i % 4; int l = 5 + (i%4); if (subs.should_gather(sys, l)) { - Entry *e = new Entry(ceph_clock_now(), - pthread_self(), - l, - sys, - "hello world"); + Entry *e = log.create_entry(l, sys, "hello world"); log.submit_entry(e); } } @@ -58,7 +54,7 @@ TEST(Log, ManyNoGather) for (int i=0; iset_str(oss.str()); @@ -115,7 +111,7 @@ TEST(Log, ManyGatherLogStringAssignWithReserve) for (int i=0; im_static_buf, sizeof(e->m_static_buf)); ostream oss(&psb); oss << "this i a long stream asdf asdf asdf asdf asdf asdf asdf asdf asdf as fd"; @@ -161,7 +157,7 @@ TEST(Log, ManyGatherLogPrebufOverflow) for (int i=0; im_static_buf, sizeof(e->m_static_buf)); ostream oss(&psb); oss << "this i a long stream asdf asdf asdf asdf asdf asdf asdf asdf asdf as fd" @@ -185,7 +181,7 @@ TEST(Log, ManyGather) for (int i=0; iset_str(msg); -- 2.39.5