From 00d4a625269b2645ac89744bd53e158ec3222fcf Mon Sep 17 00:00:00 2001
From: Jan David Mol <mol@astron.nl>
Date: Wed, 29 May 2019 11:59:53 +0000
Subject: [PATCH] COB-66: Move logging IERS to rtcp to avoid replicating
 logspam.

---
 RTCP/Cobalt/GPUProc/src/rtcp.cc            |  8 ++++++++
 RTCP/Cobalt/InputProc/src/Delays/Delays.cc | 10 ----------
 RTCP/Cobalt/InputProc/src/Delays/Delays.h  | 11 +++++++++++
 3 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/RTCP/Cobalt/GPUProc/src/rtcp.cc b/RTCP/Cobalt/GPUProc/src/rtcp.cc
index ea73929a3b2..791ddfdaa5e 100644
--- a/RTCP/Cobalt/GPUProc/src/rtcp.cc
+++ b/RTCP/Cobalt/GPUProc/src/rtcp.cc
@@ -61,6 +61,7 @@
 #include <CoInterface/Stream.h>
 #include <CoInterface/SelfDestructTimer.h>
 #include <InputProc/SampleType.h>
+#include <InputProc/Delays/Delays.h>
 #include <InputProc/WallClockTime.h>
 #include <InputProc/Buffer/StationID.h>
 
@@ -418,6 +419,13 @@ int main(int argc, char **argv)
     LOG_WARN_STR("Cannot lock all memory: " << ex.what());
   }
 
+  // IERS table information
+  struct Delays::IERS_tablestats stats = Delays::get_IERS_tablestats();
+
+  LOG_INFO_STR("Using IERS table " << stats.realpath
+            << ", last entry is " << TimeDouble::toString(stats.last_entry_timestamp, false)
+            << ", table written on " << TimeDouble::toString(stats.last_fs_modification, false));
+
   /*
    * RUN stage
    */
diff --git a/RTCP/Cobalt/InputProc/src/Delays/Delays.cc b/RTCP/Cobalt/InputProc/src/Delays/Delays.cc
index 240c3e9aabe..3a43bcc62fb 100644
--- a/RTCP/Cobalt/InputProc/src/Delays/Delays.cc
+++ b/RTCP/Cobalt/InputProc/src/Delays/Delays.cc
@@ -52,11 +52,6 @@ namespace LOFAR
 {
   namespace Cobalt
   {
-    static std::string time2str(const time_t time)
-    {
-      return TimeDouble::toString(time, false);
-    }
-
     //##----------------  Public methods  ----------------##//
 
     Delays::Delays(const Parset &parset, size_t stationIdx, const TimeStamp &from, size_t increment)
@@ -70,11 +65,6 @@ namespace LOFAR
       ASSERTSTR(test(), "Delay compensation engine is broken");
 
       init();
-
-      // Log TAI_UTC table information to inform the user about the age of the delay information we're about to use
-      struct IERS_tablestats stats = get_IERS_tablestats();
-
-      LOG_INFO_STR("Using IERS table " << stats.realpath << ", last entry is " << time2str(stats.last_entry_timestamp) << ", table written on " << time2str(stats.last_fs_modification));
     }
 
 
diff --git a/RTCP/Cobalt/InputProc/src/Delays/Delays.h b/RTCP/Cobalt/InputProc/src/Delays/Delays.h
index f81abb6241f..cd85ef8b4e9 100644
--- a/RTCP/Cobalt/InputProc/src/Delays/Delays.h
+++ b/RTCP/Cobalt/InputProc/src/Delays/Delays.h
@@ -45,6 +45,8 @@
 #include <casacore/casa/Quanta/MVDirection.h>
 #include <casacore/casa/Quanta/MVPosition.h>
 #include <casacore/casa/Quanta/MVEpoch.h>
+
+#include <ctime>
 #endif
 
 namespace LOFAR
@@ -149,6 +151,15 @@ namespace LOFAR
        */
       void generateMetaData( const AllDelays &delaysAtBegin, const AllDelays &delaysAfterEnd, const std::vector<size_t> &subbands, std::vector<SubbandMetaData> &metaDatas, std::vector<ssize_t> &read_offsets );
 
+      struct IERS_tablestats {
+        std::string path;     // path to the IERS table, as provided by casacore
+        std::string realpath; // path to the IERS table, with all symlinks resolved
+        time_t last_fs_modification; // last modification to the IERS table, according to the file system (f.e. when table was written)
+        time_t last_entry_timestamp; // timestamp of last entry in the table
+      };
+
+      static struct IERS_tablestats get_IERS_tablestats();
+
     private:
       const Parset &parset;
       const size_t stationIdx;
-- 
GitLab