From d249ff11a577a520d78b750d188a2a5b61123e71 Mon Sep 17 00:00:00 2001 From: Matej Ferencevic Date: Wed, 4 Oct 2017 16:20:38 +0200 Subject: [PATCH] Misc glog and gflags fixes. Summary: Log files aren't created by default anymore. All logs are reported to stderr by default. Normalized flag names. Removed unnecessary flags from gflags. Reviewers: teon.banek Reviewed By: teon.banek Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D856 --- libs/CMakeLists.txt | 11 +++++------ libs/setup.sh | 4 ++-- src/memgraph_bolt.cpp | 7 +++++-- tests/stress/continuous_integration | 2 +- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/libs/CMakeLists.txt b/libs/CMakeLists.txt index 39d0034f6..ebf19e136 100644 --- a/libs/CMakeLists.txt +++ b/libs/CMakeLists.txt @@ -138,11 +138,9 @@ import_external_library(gflags STATIC -DGFLAGS_NO_FILENAMES=${GFLAGS_NO_FILENAMES}) # Setup google logging after gflags (so that glog can use it). -set(GLOG_NO_FILENAMES "0") -set(GLOG_NO_STACKTRACE "0") +set(GLOG_DISABLE_OPTIONS "0") if ("${CMAKE_BUILD_TYPE}" MATCHES "^(R|r)(E|e)(L|l).+") - set(GLOG_NO_FILENAMES "1") - set(GLOG_NO_STACKTRACE "1") + set(GLOG_DISABLE_OPTIONS "1") endif() # Setup google logging after gflags (so that glog can use it). @@ -151,8 +149,9 @@ import_external_library(glog STATIC ${CMAKE_CURRENT_SOURCE_DIR}/glog/include DEPENDS gflags-proj CMAKE_ARGS -Dgflags_DIR=${CMAKE_CURRENT_SOURCE_DIR}/gflags/lib/cmake/gflags - -DGLOG_NO_FILENAMES=${GLOG_NO_FILENAMES} - -DGLOG_NO_STACKTRACE=${GLOG_NO_STACKTRACE}) + -DGLOG_NO_FILENAMES=${GLOG_DISABLE_OPTIONS} + -DGLOG_NO_STACKTRACE=${GLOG_DISABLE_OPTIONS} + -DGLOG_NO_BUFFER_SETTINGS=${GLOG_DISABLE_OPTIONS}) # Setup cppitertools import_header_library(cppitertools ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/libs/setup.sh b/libs/setup.sh index 8733a600f..fb1dcc675 100755 --- a/libs/setup.sh +++ b/libs/setup.sh @@ -67,7 +67,7 @@ cd .. # google logging git clone https://github.com/memgraph/glog.git -glog_tag="b5e33a7468cf7da6412eb50d1e8e704da471f49f" # custom version (v0.3.5+) +glog_tag="a6ee5ef590190cdb9f69cccc2db99dc5994b2f92" # custom version (v0.3.5+) cd glog git checkout ${glog_tag} cd .. @@ -82,7 +82,7 @@ cd .. # google flags git clone https://github.com/memgraph/gflags.git -gflags_tag="69ce2926338522788d500e916736ef47e70dd905" # custom version (May 6, 2017) +gflags_tag="18c4a5d151f7828c62d838ef513b4db290e5324c" # custom version (May 6, 2017) cd gflags git checkout ${gflags_tag} cd .. diff --git a/src/memgraph_bolt.cpp b/src/memgraph_bolt.cpp index e9862c1c0..ff0dd6b9d 100644 --- a/src/memgraph_bolt.cpp +++ b/src/memgraph_bolt.cpp @@ -37,8 +37,10 @@ DEFINE_string(port, "7687", "Communication port on which to listen."); DEFINE_VALIDATED_int32(num_workers, std::max(std::thread::hardware_concurrency(), 1U), "Number of workers", FLAG_IN_RANGE(1, INT32_MAX)); -DEFINE_string(log_file, "memgraph.log", +DEFINE_string(log_file, "", "Path to where the log should be stored."); +DEFINE_string(log_link_basename, "", + "Basename used for symlink creation to the last log file."); DEFINE_uint64(memory_warning_threshold, 1024, "Memory warning treshold, in MB. If Memgraph detects there is " "less available RAM available it will log a warning. Set to 0 to " @@ -70,7 +72,7 @@ void load_config(int &argc, char **&argv) { for (const auto &config : configs) if (fs::exists(config)) { flagfile_arguments.emplace_back( - std::string("--flagfile=" + config.generic_string())); + std::string("--flag-file=" + config.generic_string())); } int custom_argc = static_cast(flagfile_arguments.size()) + 1; @@ -101,6 +103,7 @@ int main(int argc, char **argv) { google::InitGoogleLogging(argv[0]); google::SetLogDestination(google::INFO, FLAGS_log_file.c_str()); + google::SetLogSymlink(google::INFO, FLAGS_log_link_basename.c_str()); // Unhandled exception handler init. std::set_terminate(&terminate_handler); diff --git a/tests/stress/continuous_integration b/tests/stress/continuous_integration index 5c6c8eb11..502129d59 100755 --- a/tests/stress/continuous_integration +++ b/tests/stress/continuous_integration @@ -135,7 +135,7 @@ if not os.path.exists(args.memgraph): cwd = os.path.dirname(args.memgraph) cmd = [args.memgraph, "--num-workers=" + str(THREADS)] if not args.verbose: - cmd += ["--minloglevel", "1"] + cmd += ["--min-log-level", "1"] if args.log_file: cmd += ["--log-file", args.log_file] if args.snapshot_directory: