diff --git a/src/communication/server.hpp b/src/communication/server.hpp index 0d7b5a709..f70a086ed 100644 --- a/src/communication/server.hpp +++ b/src/communication/server.hpp @@ -55,21 +55,24 @@ class Server } void Start(size_t n) { + logger_.info("Starting {} workers", n); workers_.reserve(n); - for (size_t i = 0; i < n; ++i) { workers_.push_back( std::make_shared<Worker<Session, OutputStream, Socket>>( dbms_, query_engine_)); workers_.back()->Start(alive_); } - + logger_.info("Server is fully armed and operational"); + logger_.info("Listening on {} at {}", socket_.endpoint().address(), + socket_.endpoint().port()); while (alive_) { this->WaitAndProcessEvents(); } } void Shutdown() { + logger_.info("Shutting down..."); alive_.store(false); for (auto &worker : workers_) worker->thread_.join(); @@ -114,4 +117,5 @@ class Server Event event_; Logger logger_; }; -} + +} // namespace communication diff --git a/src/memgraph_bolt.cpp b/src/memgraph_bolt.cpp index 4f9d86b9c..3fcf8a653 100644 --- a/src/memgraph_bolt.cpp +++ b/src/memgraph_bolt.cpp @@ -18,7 +18,7 @@ #include "utils/flag_validation.hpp" #include "utils/signals/handler.hpp" -#include "utils/stacktrace/log.hpp" +#include "utils/stacktrace.hpp" #include "utils/terminate_handler.hpp" namespace fs = std::experimental::filesystem; @@ -39,11 +39,6 @@ DEFINE_VALIDATED_int32(num_workers, std::max(std::thread::hardware_concurrency(), 1U), "Number of workers", FLAG_IN_RANGE(1, INT32_MAX)); -void throw_and_stacktace(std::string message) { - Stacktrace stacktrace; - logger.info(stacktrace.dump()); -} - // Load flags in this order, the last one has the highest priority: // 1) /etc/memgraph/config // 2) ~/.memgraph/config @@ -85,6 +80,14 @@ void load_config(int &argc, char **&argv) { gflags::ParseCommandLineFlags(&argc, &argv, true); } +void log_stacktrace(const std::string &title) { + Stacktrace stacktrace; + // TODO: Change this from 'info' to 'error', when default error logging is + // added. + logging::info(title); + logging::info(stacktrace.dump()); +} + int main(int argc, char **argv) { fs::current_path(fs::path(argv[0]).parent_path()); load_config(argc, argv); @@ -99,7 +102,7 @@ int main(int argc, char **argv) { // Get logger. logger = logging::log->logger("Main"); - logger.info("{}", logging::log->type()); + logger.debug("Using {} logger", logging::log->type()); // Unhandled exception handler init. std::set_terminate(&terminate_handler); @@ -139,8 +142,6 @@ int main(int argc, char **argv) { std::exit(EXIT_FAILURE); } - logger.info("Listening on {} at {}", FLAGS_interface, FLAGS_port); - Dbms dbms; QueryEngine<result_stream_t> query_engine; @@ -156,9 +157,7 @@ int main(int argc, char **argv) { [&server]() { server.Shutdown(); }); // Start worker threads. - logger.info("Starting {} workers", FLAGS_num_workers); server.Start(FLAGS_num_workers); - logger.info("Shutting down..."); return EXIT_SUCCESS; } diff --git a/src/utils/assert.hpp b/src/utils/assert.hpp index 8d3b35891..e9af9e246 100644 --- a/src/utils/assert.hpp +++ b/src/utils/assert.hpp @@ -7,7 +7,7 @@ #include <iostream> #include <sstream> -#include "utils/stacktrace/stacktrace.hpp" +#include "utils/stacktrace.hpp" /** * if STACKTRACE_ASSERT_ON is defined the full stacktrace will be printed on diff --git a/src/utils/exceptions.hpp b/src/utils/exceptions.hpp index 4ec0241e7..4997f0799 100644 --- a/src/utils/exceptions.hpp +++ b/src/utils/exceptions.hpp @@ -9,7 +9,7 @@ #include <fmt/format.h> #include <fmt/ostream.h> -#include "utils/stacktrace/stacktrace.hpp" +#include "utils/stacktrace.hpp" namespace utils { diff --git a/src/utils/stacktrace/stacktrace.hpp b/src/utils/stacktrace.hpp similarity index 100% rename from src/utils/stacktrace/stacktrace.hpp rename to src/utils/stacktrace.hpp diff --git a/src/utils/stacktrace/log.hpp b/src/utils/stacktrace/log.hpp deleted file mode 100644 index 5b176f3fb..000000000 --- a/src/utils/stacktrace/log.hpp +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once - -#include "logging/default.hpp" -#include "utils/stacktrace/stacktrace.hpp" - -void log_stacktrace(const std::string& title) { - Stacktrace stacktrace; - logging::info(title); - logging::info(stacktrace.dump()); -} diff --git a/src/utils/terminate_handler.hpp b/src/utils/terminate_handler.hpp index 79a2d9481..9b6a7ceef 100644 --- a/src/utils/terminate_handler.hpp +++ b/src/utils/terminate_handler.hpp @@ -1,7 +1,7 @@ #pragma once #include "utils/auto_scope.hpp" -#include "utils/stacktrace/stacktrace.hpp" +#include "utils/stacktrace.hpp" #include <execinfo.h> #include <iostream> diff --git a/tests/unit/fswatcher.cpp b/tests/unit/fswatcher.cpp index 151ed3514..c378adac6 100644 --- a/tests/unit/fswatcher.cpp +++ b/tests/unit/fswatcher.cpp @@ -5,7 +5,6 @@ #include "logging/default.cpp" #include "utils/fswatcher.hpp" #include "utils/signals/handler.hpp" -#include "utils/stacktrace/log.hpp" #include "utils/terminate_handler.hpp" using namespace std::chrono_literals; diff --git a/tests/unit/signal_handler.cpp b/tests/unit/signal_handler.cpp index 210d61ff2..82f2eb690 100644 --- a/tests/unit/signal_handler.cpp +++ b/tests/unit/signal_handler.cpp @@ -5,7 +5,7 @@ #include <utility> #include "utils/signals/handler.hpp" -#include "utils/stacktrace/stacktrace.hpp" +#include "utils/stacktrace.hpp" TEST(SignalHandler, SegmentationFaultTest) { SignalHandler::register_handler(Signal::SegmentationFault, []() {