This is an automated email from the ASF dual-hosted git repository. adar pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/kudu.git
commit 8d92905a472e5b010d8f1bdfbe1770fd564ce082 Author: Adar Dembo <[email protected]> AuthorDate: Sat Mar 28 01:25:43 2020 -0700 logging: remove kudu::Bind usage from LoggingCallback Change-Id: I8d3c995617ace2a5974be1104fa6f22b3ee5acea Reviewed-on: http://gerrit.cloudera.org:8080/15577 Tested-by: Kudu Jenkins Reviewed-by: Alexey Serbin <[email protected]> Reviewed-by: Andrew Wong <[email protected]> --- src/kudu/client/client.cc | 8 +++++--- src/kudu/util/logging.cc | 4 ++-- src/kudu/util/logging_callback.h | 20 ++++++++------------ 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/kudu/client/client.cc b/src/kudu/client/client.cc index 67976e0..e602eb6 100644 --- a/src/kudu/client/client.cc +++ b/src/kudu/client/client.cc @@ -69,8 +69,6 @@ #include "kudu/common/wire_protocol.pb.h" #include "kudu/consensus/metadata.pb.h" #include "kudu/gutil/basictypes.h" -#include "kudu/gutil/bind.h" -#include "kudu/gutil/bind_helpers.h" #include "kudu/gutil/casts.h" #include "kudu/gutil/ref_counted.h" #include "kudu/gutil/stl_util.h" @@ -234,7 +232,11 @@ static void LoggingAdapterCB(KuduLoggingCallback* user_cb, } void InstallLoggingCallback(KuduLoggingCallback* cb) { - RegisterLoggingCallback(Bind(&LoggingAdapterCB, Unretained(cb))); + RegisterLoggingCallback( + [=](LogSeverity severity, const char* filename, int line_number, + const struct ::tm* time, const char* message, size_t message_len) { + LoggingAdapterCB(cb, severity, filename, line_number, time, message, message_len); + }); } void UninstallLoggingCallback() { diff --git a/src/kudu/util/logging.cc b/src/kudu/util/logging.cc index 0ad4504..96b9a54 100644 --- a/src/kudu/util/logging.cc +++ b/src/kudu/util/logging.cc @@ -24,6 +24,7 @@ #include <cstdlib> #include <ctime> #include <fstream> +#include <functional> #include <initializer_list> #include <mutex> #include <utility> @@ -34,7 +35,6 @@ #include <glog/logging.h> #include "kudu/gutil/basictypes.h" -#include "kudu/gutil/callback.h" // IWYU pragma: keep #include "kudu/gutil/port.h" #include "kudu/gutil/spinlock.h" #include "kudu/gutil/stringprintf.h" @@ -118,7 +118,7 @@ class SimpleSink : public google::LogSink { default: LOG(FATAL) << "Unknown glog severity: " << severity; } - cb_.Run(kudu_severity, full_filename, line, tm_time, message, message_len); + cb_(kudu_severity, full_filename, line, tm_time, message, message_len); } private: diff --git a/src/kudu/util/logging_callback.h b/src/kudu/util/logging_callback.h index 83fb973..5920bea 100644 --- a/src/kudu/util/logging_callback.h +++ b/src/kudu/util/logging_callback.h @@ -14,14 +14,12 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. -#ifndef KUDU_UTIL_LOGGING_CALLBACK_H -#define KUDU_UTIL_LOGGING_CALLBACK_H +#pragma once #include <ctime> +#include <functional> #include <string> -#include "kudu/gutil/callback_forward.h" - namespace kudu { enum LogSeverity { @@ -34,13 +32,11 @@ enum LogSeverity { // Callback for simple logging. // // 'message' is NOT terminated with an endline. -typedef Callback<void(LogSeverity severity, - const char* filename, - int line_number, - const struct ::tm* time, - const char* message, - size_t message_len)> LoggingCallback; +typedef std::function<void(LogSeverity severity, + const char* filename, + int line_number, + const struct ::tm* time, + const char* message, + size_t message_len)> LoggingCallback; } // namespace kudu - -#endif
