From b8803b1e04b9a8d7fb117ff1f18273e7d2b560ca Mon Sep 17 00:00:00 2001 From: Babicaa Date: Fri, 26 Apr 2019 15:28:21 +0200 Subject: [PATCH] Cosmetic improvements to WriterManager --- lib/src/WriterManager.cpp | 24 ++++++++++++++++-------- lib/src/WriterManager.hpp | 5 +++-- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/lib/src/WriterManager.cpp b/lib/src/WriterManager.cpp index 9f6a17c..d4c5474 100644 --- a/lib/src/WriterManager.cpp +++ b/lib/src/WriterManager.cpp @@ -14,15 +14,18 @@ void writer_utils::set_process_id(int user_id) #ifdef DEBUG_OUTPUT using namespace date; - cout << "[" << std::chrono::system_clock::now() << "]"; + using namespace chrono; + error_message << "[" << system_clock::now() << "]"; cout << "[writer_utils::set_process_id] Setting process user to "; cout << user_id << endl; #endif if (setegid(user_id)) { stringstream error_message; + using namespace date; - error_message << "[" << std::chrono::system_clock::now() << "]"; + using namespace chrono; + error_message << "[" << system_clock::now() << "]"; error_message << "[writer_utils::set_process_id] Cannot set group_id to "; error_message << user_id << endl; @@ -32,7 +35,8 @@ void writer_utils::set_process_id(int user_id) if (seteuid(user_id)) { stringstream error_message; using namespace date; - error_message << "[" << std::chrono::system_clock::now() << "]"; + using namespace chrono; + error_message << "[" << system_clock::now() << "]"; error_message << "[writer_utils::set_process_id] Cannot set user_id to "; error_message << user_id << endl; @@ -46,8 +50,10 @@ void writer_utils::create_destination_folder(const string& output_file) if (file_separator_index != string::npos) { string output_folder(output_file.substr(0, file_separator_index)); + using namespace date; - cout << "[" << std::chrono::system_clock::now() << "]"; + using namespace chrono; + cout << "[" << system_clock::now() << "]"; cout << "[writer_utils::create_destination_folder] Creating folder "; cout << output_folder << endl; @@ -74,10 +80,10 @@ WriterManager::WriterManager( n_frames_to_receive = 0; n_frames_to_write = 0; - #ifdef DEBUG_OUTPUT using namespace date; - cout << "[" << std::chrono::system_clock::now() << + using namespace chrono; + error_message << "[" << system_clock::now() << "]"; cout << "[WriterManager::WriterManager] Writer manager initialized." << endl; #endif } @@ -89,10 +95,12 @@ void WriterManager::stop() #ifdef DEBUG_OUTPUT using namespace date; cout << "[" << std::chrono::system_clock::now() << "]"; - cout << "[WriterManager::stop] Stopping the writer manager." << endl; + cout << "[WriterManager::stop] Stopping the writer." << endl; #endif - + running_flag = false; + + } string WriterManager::get_status() diff --git a/lib/src/WriterManager.hpp b/lib/src/WriterManager.hpp index d53ae16..76de00c 100644 --- a/lib/src/WriterManager.hpp +++ b/lib/src/WriterManager.hpp @@ -34,7 +34,6 @@ struct WriterManagerLog class WriterManager { // Initialize in constructor. - const std::deque logs; std::atomic running_flag; @@ -55,6 +54,8 @@ class WriterManager typedef std::unordered_map header_map; std::shared_ptr header_values_type = NULL; + const std::deque logs; + void write_h5(std::string output_file, uint64_t n_frames); void write_h5_format(H5::H5File& file); @@ -76,7 +77,7 @@ class WriterManager // Return True if the frame is to be received, False if is to be dropped. bool receive_frame(); - // True if the process should conitnue. + // True if the process should continue. bool is_running() const; bool is_writing() const;