ShmMonitor: Use FairLogger for timestamp calculation

This commit is contained in:
Alexey Rybalchenko 2020-08-07 10:58:16 +02:00 committed by Dennis Klein
parent be8ab06cc1
commit 86a1dd38a2
2 changed files with 10 additions and 11 deletions

View File

@ -380,6 +380,7 @@ if(BUILD_FAIRMQ)
Boost::boost Boost::boost
Boost::date_time Boost::date_time
Boost::program_options Boost::program_options
FairLogger::FairLogger
PicoSHA2 PicoSHA2
) )
target_include_directories(fairmq-shmmonitor PUBLIC target_include_directories(fairmq-shmmonitor PUBLIC

View File

@ -10,6 +10,7 @@
#include "Common.h" #include "Common.h"
#include <fairmq/Tools.h> #include <fairmq/Tools.h>
#include <fairlogger/Logger.h>
#include <boost/interprocess/managed_shared_memory.hpp> #include <boost/interprocess/managed_shared_memory.hpp>
#include <boost/interprocess/file_mapping.hpp> #include <boost/interprocess/file_mapping.hpp>
@ -79,6 +80,10 @@ Monitor::Monitor(const string& shmId, bool selfDestruct, bool interactive, bool
throw DaemonPresent(tools::ToString("fairmq-shmmonitor for shared memory id ", fShmId, " already started or not properly exited.")); throw DaemonPresent(tools::ToString("fairmq-shmmonitor for shared memory id ", fShmId, " already started or not properly exited."));
} }
} }
Logger::SetConsoleColor(false);
Logger::DefineVerbosity(Verbosity::user1, VerbositySpec::Make(VerbositySpec::Info::timestamp_us));
Logger::SetVerbosity(Verbosity::verylow);
} }
void Monitor::CatchSignals() void Monitor::CatchSignals()
@ -309,17 +314,10 @@ void Monitor::CheckSegment()
<< setw(10) << (fViewOnly ? "view only" : to_string(duration)) << " |" << setw(10) << (fViewOnly ? "view only" : to_string(duration)) << " |"
<< c << flush; << c << flush;
} else if (fViewOnly) { } else if (fViewOnly) {
time_t current = chrono::system_clock::to_time_t(now); LOGV(info, user1) << "name: " << fSegmentName
chrono::milliseconds ms = chrono::duration_cast<chrono::milliseconds>(now.time_since_epoch());
struct tm local;
localtime_r(&current, &local);
char timeBuffer[80];
size_t count = strftime(timeBuffer, 80, "%F %T", &local);
cout << (count != 0 ? timeBuffer : "") << "." << setfill('0') << setw(6) << ms.count() % 1000000
<< ", name: " << fSegmentName
<< ", size: " << segment.get_size() << ", size: " << segment.get_size()
<< ", free: " << segment.get_free_memory() << ", free: " << segment.get_free_memory()
<< ", numDevices: " << numDevices << endl; << ", numDevices: " << numDevices;
} }
} catch (bie&) { } catch (bie&) {
fHeartbeatTriggered = false; fHeartbeatTriggered = false;