Index: trunk/BNC/CHANGELOG.md
===================================================================
--- trunk/BNC/CHANGELOG.md	(revision 11186)
+++ trunk/BNC/CHANGELOG.md	(revision 11187)
@@ -1,5 +1,5 @@
 # Changelog
 ## 2.13.8 (2026-11-04)
-- ADDED: **Structured logfile** (General options 'Structured logfile', 'Format' and 'Min. level', keys logFileStructured, logFormatStructured and logLevelStructured): in addition to the unchanged logfile, the same records as JSON Lines ('json', default) or key=value pairs ('logfmt'), daily file '_YYMMDD' like the logfile; each record has time in UTC ('time') and GPS Time ('gpst'), level, component, event, stream, the event's fields, the logfile text ('msg') and a version ('v'). Events with fields: ppp_position, ppp_epoch_failed, stream_format, stream_content (RTCM scan, with message_type and size of the received message types), stream_timeout, stream_outage_begin/end, stream_corrupted_begin/end, stream_latency; all other messages as event 'message' with the component of their origin (stream, ntrip, bce, ssr, ppp, cmb, upload, ssrqc, bnc) and a level (error: a function does not work; warning: data or configuration problem, BNC continues; info: status); messages of the BNC_DEBUG_BCE/OBS/CMB defines with level 'debug' and component bce/obs/cmb. Test case log_structured and check tests/tools/logcheck.py
+- ADDED: **Structured logfile** (General options 'Structured logfile', 'Format' and 'Min. level', keys logFileStructured, logFormatStructured and logLevelStructured): in addition to the unchanged logfile, the same records as JSON Lines ('json', default) or key=value pairs ('logfmt'), one appended file without date for rotation by logrotate & co (reopened if moved or removed); each record has the time in UTC ('time'), for records of a data epoch its GPS Time ('epoch'), level, component, event, mountpoint ('mp'), the event's fields, the logfile text ('msg') and a version ('v'). Events with fields: ppp_position, ppp_epoch_failed, stream_format, stream_content (RTCM scan, with message_type and size of the received message types and short msg 'Received message'), stream_timeout, stream_outage_begin/end, stream_corrupted_begin/end, stream_latency; all other messages as event 'message' with the component of their origin (stream, ntrip, bce, ssr, ppp, cmb, upload, ssrqc, bnc) and a level (error: a function does not work; warning: data or configuration problem, BNC continues; info: status); messages of the BNC_DEBUG_BCE/OBS/CMB defines with level 'debug' and component bce/obs/cmb. Test case log_structured and check tests/tools/logcheck.py
 - FIXED: Build with BNC_DEBUG_BCE: undeclared message number in the debug messages of the Galileo ephemeris decoder
 - ADDED: **epoch/velocity fields to PPP coordinates file to allow BNC to propagate the reference coordinates** related to a dedicated reference epoch to the current processing epoch internally; coordinates can also be given as latitude/longitude/height
Index: trunk/BNC/src/bnccore.cpp
===================================================================
--- trunk/BNC/src/bnccore.cpp	(revision 11186)
+++ trunk/BNC/src/bnccore.cpp	(revision 11187)
@@ -43,4 +43,7 @@
 #include <QMessageBox>
 #include <cmath>
+#ifndef Q_OS_WIN
+#include <sys/stat.h>
+#endif
 
 #include "bnccore.h"
@@ -72,4 +75,5 @@
   _logStream   = 0;
   _logFileStructured  = 0;
+  _logStructuredInit  = false;
   _logFormatStructured = t_logRecord::json;
   _logLevelStructured  = t_logRecord::debug;
@@ -195,5 +199,4 @@
     delete _logStream; _logStream = 0;
     delete _logFile;   _logFile   = 0;
-    delete _logFileStructured; _logFileStructured = 0;
     _logFileFlag = 1;
     _fileDate = currDate;
@@ -214,17 +217,23 @@
       _logStream->setDevice(_logFile);
     }
-    QString structName = settings.value("logFileStructured").toString();
-    if ( !structName.isEmpty() ) {
-      expandEnvVar(structName);
+  }
+
+  // Structured logfile: one endless file (rotation by external tools)
+  // ---------------------------------------------------------------
+  if (!_logStructuredInit) {
+    _logStructuredInit = true;
+    bncSettings settings;
+    _logFileStructuredName = settings.value("logFileStructured").toString();
+    if (!_logFileStructuredName.isEmpty()) {
+      expandEnvVar(_logFileStructuredName);
       _logFormatStructured = t_logRecord::formatFromString(
                                settings.value("logFormatStructured").toString());
       _logLevelStructured  = t_logRecord::levelFromString(
                                settings.value("logLevelStructured").toString());
-      _logFileStructured = new QFile(structName + "_" + currDate.toString("yyMMdd"));
-      if (!_logFileStructured->open(append ? (QIODevice::WriteOnly | QIODevice::Append)
-                                           : QIODevice::WriteOnly)) {
-        delete _logFileStructured; _logFileStructured = 0;
-      }
-    }
+      openLogFileStructured();
+    }
+  }
+  else if (!_logFileStructuredName.isEmpty() && _logStructuredCheck.hasExpired(1000)) {
+    openLogFileStructured();   // reopens only if the file was moved or removed
   }
 
@@ -244,4 +253,31 @@
     _logFileStructured->write(rec.encode(_logFormatStructured, currDateTime) + "\n");
     _logFileStructured->flush();
+  }
+}
+
+// Open the structured logfile, or reopen it after an external rotation
+// (logrotate without copytruncate moves the file and the old one must be
+// released); always appending, also after copytruncate
+////////////////////////////////////////////////////////////////////////////
+void t_bncCore::openLogFileStructured() {
+  _logStructuredCheck.start();
+  if (_logFileStructured) {
+    bool same = _logFileStructured->exists();
+#ifndef Q_OS_WIN
+    if (same) {
+      struct stat stPath, stOpen;
+      same = (stat(QFile::encodeName(_logFileStructuredName).constData(), &stPath) == 0 &&
+              fstat(_logFileStructured->handle(), &stOpen) == 0 &&
+              stPath.st_dev == stOpen.st_dev && stPath.st_ino == stOpen.st_ino);
+    }
+#endif
+    if (same) {
+      return;
+    }
+    delete _logFileStructured; _logFileStructured = 0;
+  }
+  _logFileStructured = new QFile(_logFileStructuredName);
+  if (!_logFileStructured->open(QIODevice::WriteOnly | QIODevice::Append)) {
+    delete _logFileStructured; _logFileStructured = 0;
   }
 }
Index: trunk/BNC/src/bnccore.h
===================================================================
--- trunk/BNC/src/bnccore.h	(revision 11186)
+++ trunk/BNC/src/bnccore.h	(revision 11187)
@@ -25,4 +25,6 @@
 #ifndef BNCAPP_H
 #define BNCAPP_H
+
+#include <QElapsedTimer>
 
 #include "bnctime.h"
@@ -183,4 +185,5 @@
                        const QString& strV4);
   void  messagePrivate(const t_logRecord& rec);
+  void  openLogFileStructured();
 
   QSettings::SettingsMap _settings;
@@ -189,4 +192,7 @@
   int                    _logFileFlag;
   QFile*                 _logFileStructured;
+  QString                _logFileStructuredName;
+  bool                   _logStructuredInit;
+  QElapsedTimer          _logStructuredCheck;
   t_logRecord::e_format  _logFormatStructured;
   t_logRecord::e_level   _logLevelStructured;
Index: trunk/BNC/src/bncgetthread.cpp
===================================================================
--- trunk/BNC/src/bncgetthread.cpp	(revision 11186)
+++ trunk/BNC/src/bncgetthread.cpp	(revision 11187)
@@ -840,4 +840,5 @@
         t_logRecord rec(t_logRecord::info, "stream", "stream_content", _staID,
                         _staID + ": Received message type " + type.toLatin1() +  size.toLatin1());
+        rec.setStructuredMsg("Received message");
         rec.add("message_type", int(decoder()->_typeList[ii]._type));
         if (decoder()->_typeList[ii]._size) {
Index: trunk/BNC/src/bnchelp.html
===================================================================
--- trunk/BNC/src/bnchelp.html	(revision 11186)
+++ trunk/BNC/src/bnchelp.html	(revision 11187)
@@ -2787,7 +2787,9 @@
     For log processing tools (e.g. Grafana Loki, Elasticsearch, Vector, jq), BNC can write the same records in
     addition into a structured logfile: specify its path in the 'Structured logfile' field and select the format,
-    'json' for one JSON object per line (JSON Lines) or 'logfmt' for key=value pairs separated by blanks. As for the
-    logfile, the name is extended by '_YYMMDD'. The logfile itself remains unchanged, so existing scripts reading it
-    keep working. Default is an empty option field, meaning that no structured logfile is written. 'Min. level'
+    'json' for one JSON object per line (JSON Lines) or 'logfmt' for key=value pairs separated by blanks. Unlike the
+    logfile, the structured logfile is one file without date in its name, always appended (also without 'Append
+    files'), meant to be rotated by an external tool such as logrotate: if the file is moved or removed, BNC
+    continues with a new file of the same name within one second; 'copytruncate' works as well. The logfile itself
+    remains unchanged, so existing scripts reading it keep working. Default is an empty option field, meaning that no structured logfile is written. 'Min. level'
     restricts the structured logfile to records of at least the selected level: 'debug' (default) writes all records,
     'info' leaves out the debug records, 'warning' writes warnings and errors, 'error' errors only.
@@ -2798,5 +2800,6 @@
   <ul>
     <li>'time': time of the record in UTC, ISO 8601 with 'Z', e.g. '2025-11-17T13:49:40.000Z',</li>
-    <li>'gpst': the same time in GPS Time (as the time stamps of the logfile), e.g. '2025-11-17T13:49:58.000',</li>
+    <li>'epoch': GPS Time of the data epoch the record refers to, ISO 8601 without 'Z', e.g. '2025-11-17T13:49:10.000';
+        only in records of an epoch ('ppp_position', 'ppp_epoch_failed'),</li>
     <li>'level': 'debug', 'info', 'warning' or 'error'; debug records exist only in BNC versions built with the
         defines BNC_DEBUG_BCE, BNC_DEBUG_OBS or BNC_DEBUG_CMB (src/src.pri),</li>
@@ -2806,7 +2809,7 @@
         (SSR QC), or 'bnc' for general messages,</li>
     <li>'event': the kind of record, see below, or 'message' for general messages,</li>
-    <li>'stream': the stream (mountpoint) or the PPP station, if known,</li>
+    <li>'mp': the mountpoint of the stream or the PPP station, if known,</li>
     <li>the fields of the event,</li>
-    <li>'msg': the text of the record in the logfile,</li>
+    <li>'msg': the text of the record in the logfile (shortened where the fields carry the details),</li>
     <li>'v': the version of the record layout, currently 1.</li>
   </ul>
@@ -2815,5 +2818,5 @@
   </p>
   <ul>
-    <li>'ppp_position': 'epoch' (GPS Time), 'x', 'y', 'z', 'dn', 'de', 'du', 'trp0', 'trp', 'trp_stdev', 'num_sat',
+    <li>'ppp_position': 'x', 'y', 'z', 'dn', 'de', 'du', 'trp0', 'trp', 'trp_stdev', 'num_sat',
         'hdop', 'fixed' (true/false), 'fix_percent'; 'ppp_epoch_failed' (warning) if no solution was computed,</li>
     <li>'stream_format': 'decoder' (RTCM2, RTCM3, ZERO, ZERO2FILE, RTNET) and 'format' (format entry of the stream),</li>
@@ -2821,5 +2824,6 @@
     <li>'stream_content': content of the stream found by the RTCM scan (see section <a href=#miscscan>2.12.3</a>), e.g. observation
         types, antenna and receiver descriptors, antenna coordinates, GLONASS slots, CRS and Helmert parameters; for the
-        received message types with the fields 'message_type' and, if known, 'size' (bytes),</li>
+        received message types with the fields 'message_type' and, if known, 'size' (bytes) and the short 'msg'
+        'Received message' (logfile: 'Received message type 1127 (size 618)'),</li>
     <li>'stream_outage_begin' (warning), 'stream_corrupted_begin' (warning): 'since' (UTC);
         'stream_outage_end', 'stream_corrupted_end': 'ended' and 'since' (UTC),</li>
@@ -2839,6 +2843,6 @@
   </p>
   <pre><p style="font-family:Monospace">
-{"time":"2025-11-17T13:48:51.000Z","gpst":"2025-11-17T13:49:09.000","level":"info","component":"stream","event":"stream_format","stream":"BCEP00BKG0","decoder":"RTCM3","format":"RTCM_3.3","msg":"BCEP00BKG0: Get data in RTCM 3.x format","v":1}
-{"time":"2025-11-17T13:49:40.000Z","gpst":"2025-11-17T13:49:58.000","level":"info","component":"ppp","event":"ppp_position","stream":"WTZR00DEU0","epoch":"2025-11-17T13:49:10.000","x":4075580.2172,"y":931854.1555,"z":4801568.3403,"dn":0.0000,"de":0.0000,"du":0.0001,"trp0":2.1833,"trp":0.0019,"trp_stdev":0.0993,"num_sat":17,"hdop":0.59,"fixed":false,"fix_percent":0,"msg":"2025-11-17_13:49:10.000 WTZR00DEU0 X = 4075580.2172 ...","v":1}
+{"time":"2025-11-17T13:48:51.000Z","level":"info","component":"stream","event":"stream_format","mp":"BCEP00BKG0","decoder":"RTCM3","format":"RTCM_3.3","msg":"BCEP00BKG0: Get data in RTCM 3.x format","v":1}
+{"time":"2025-11-17T13:49:40.000Z","epoch":"2025-11-17T13:49:10.000","level":"info","component":"ppp","event":"ppp_position","mp":"WTZR00DEU0","x":4075580.2172,"y":931854.1555,"z":4801568.3403,"dn":0.0000,"de":0.0000,"du":0.0001,"trp0":2.1833,"trp":0.0019,"trp_stdev":0.0993,"num_sat":17,"hdop":0.59,"fixed":false,"fix_percent":0,"msg":"2025-11-17_13:49:10.000 WTZR00DEU0 X = 4075580.2172 ...","v":1}
 </pre>
   </p>
@@ -2847,6 +2851,6 @@
   </p>
   <pre><p style="font-family:Monospace">
-time=2025-11-17T13:48:51.000Z gpst=2025-11-17T13:49:09.000 level=info component=stream event=stream_format stream=BCEP00BKG0 decoder=RTCM3 format=RTCM_3.3 msg="BCEP00BKG0: Get data in RTCM 3.x format" v=1
-time=2025-11-17T13:49:40.000Z gpst=2025-11-17T13:49:58.000 level=info component=ppp event=ppp_position stream=WTZR00DEU0 epoch=2025-11-17T13:49:10.000 x=4075580.2172 y=931854.1555 z=4801568.3403 dn=0.0000 de=0.0000 du=0.0001 trp0=2.1833 trp=0.0019 trp_stdev=0.0993 num_sat=17 hdop=0.59 fixed=false fix_percent=0 msg="2025-11-17_13:49:10.000 WTZR00DEU0 X = 4075580.2172 ..." v=1
+time=2025-11-17T13:48:51.000Z level=info component=stream event=stream_format mp=BCEP00BKG0 decoder=RTCM3 format=RTCM_3.3 msg="BCEP00BKG0: Get data in RTCM 3.x format" v=1
+time=2025-11-17T13:49:40.000Z epoch=2025-11-17T13:49:10.000 level=info component=ppp event=ppp_position mp=WTZR00DEU0 x=4075580.2172 y=931854.1555 z=4801568.3403 dn=0.0000 de=0.0000 du=0.0001 trp0=2.1833 trp=0.0019 trp_stdev=0.0993 num_sat=17 hdop=0.59 fixed=false fix_percent=0 msg="2025-11-17_13:49:10.000 WTZR00DEU0 X = 4075580.2172 ..." v=1
 </pre>
   </p>
Index: trunk/BNC/src/bnclog.cpp
===================================================================
--- trunk/BNC/src/bnclog.cpp	(revision 11186)
+++ trunk/BNC/src/bnclog.cpp	(revision 11187)
@@ -21,4 +21,5 @@
 #include "bnclog.h"
 #include "bncutils.h"
+#include "bnctime.h"
 
 namespace {
@@ -211,4 +212,16 @@
 //
 ////////////////////////////////////////////////////////////////////////////
+t_logRecord& t_logRecord::setEpoch(const bncTime& epoch) {
+  if (epoch.valid()) {
+    _epoch = QByteArray((epoch.datestr() + 'T' + epoch.timestr(3)).c_str());
+  }
+  else {
+    _epoch.clear();
+  }
+  return *this;
+}
+
+//
+////////////////////////////////////////////////////////////////////////////
 const char* t_logRecord::levelString(e_level level) {
   switch (level) {
@@ -254,5 +267,5 @@
   QDateTime utc = gpst.addSecs(-gnumleap(dd.year(), dd.month(), dd.day()));
 
-  QByteArray msg = _msg;
+  QByteArray msg = _msgStructured.isEmpty() ? _msg : _msgStructured;
   while (msg.startsWith('\n')) {
     msg.remove(0, 1);
@@ -266,10 +279,12 @@
   };
   put("time",      utc.toString("yyyy-MM-ddThh:mm:ss.zzz").toLatin1() + "Z", true);
-  put("gpst",      gpst.toString("yyyy-MM-ddThh:mm:ss.zzz").toLatin1(), true);
+  if (!_epoch.isEmpty()) {
+    put("epoch",   _epoch, true);
+  }
   put("level",     levelString(_level), true);
   put("component", _component, true);
   put("event",     _event, true);
   if (!_stream.isEmpty()) {
-    put("stream", _stream, true);
+    put("mp", _stream, true);
   }
   all += _fields;
Index: trunk/BNC/src/bnclog.h
===================================================================
--- trunk/BNC/src/bnclog.h	(revision 11186)
+++ trunk/BNC/src/bnclog.h	(revision 11187)
@@ -31,4 +31,6 @@
 #include <QVector>
 
+class bncTime;
+
 // One record of the structured logfile (option logFileStructured).
 //
@@ -36,5 +38,10 @@
 // logfile gets one line per record, JSON (JSON Lines) or logfmt:
 //
-//   time gpst level component event [stream] [fields ...] msg v
+//   time [epoch] level component event [mp] [fields ...] msg v
+//
+// mp: mountpoint of the stream or PPP station (member _stream)
+//
+// time: time of the record in UTC; epoch: GPS Time of the data epoch the
+// record refers to (e.g. PPP position), only if set (setEpoch())
 //
 // Messages that are still emitted as plain text (newMessage(QByteArray,bool))
@@ -75,5 +82,13 @@
   t_logRecord& addTime(const char* key, const QDateTime& utc);   // ISO 8601, "Z"
 
-  // one line without line end; gpst: time of the record in GPS time
+  // shorter text for the structured logfile only, e.g. if the fields carry
+  // the details; the classic logfile keeps _msg
+  t_logRecord& setStructuredMsg(const QByteArray& msg) { _msgStructured = msg; return *this; }
+
+  // data epoch of the record (GPS Time, ISO 8601 without "Z"), key "epoch"
+  t_logRecord& setEpoch(const bncTime& epoch);
+
+  // one line without line end; gpst: time of the record in GPS Time,
+  // written as UTC (key "time")
   QByteArray encode(e_format format, const QDateTime& gpst) const;
 
@@ -89,6 +104,8 @@
   QByteArray _component;
   QByteArray _event;
+  QByteArray _epoch;
   QByteArray _stream;
   QByteArray _msg;
+  QByteArray _msgStructured;
 
  private:
Index: trunk/BNC/src/bncwindow.cpp
===================================================================
--- trunk/BNC/src/bncwindow.cpp	(revision 11186)
+++ trunk/BNC/src/bncwindow.cpp	(revision 11187)
@@ -1589,5 +1589,5 @@
   // ------------------
   _logFileLineEdit->setWhatsThis(tr("<p>Records of BNC's activities are shown in the 'Log' tab on the bottom of this window. They can be saved into a file when a valid path for that is specified in the 'Logfile (full path)' field.</p><p>The logfile name will automatically be extended by a string '_YYMMDD' carrying the current date. <i>[key: logFile]</i></p>"));
-  _logFileStructuredLineEdit->setWhatsThis(tr("<p>In addition to the logfile, BNC can write the same records as a structured logfile for log processing tools: one record per line, either JSON (JSON Lines) or logfmt (key=value pairs separated by blanks). Each record carries the time in UTC ('time', ISO 8601 with 'Z') and in GPS time ('gpst'), a level (debug, info, warning, error), the component (e.g. stream, ppp, cmb), the event (e.g. ppp_position, stream_outage_begin), the stream (mountpoint) or PPP station if known, the event's fields, the text of the classic logfile ('msg') and the record version ('v').</p><p>Messages without own event are written with event 'message' and the component of their origin; their level is error (a function does not work), warning (data or configuration problem, BNC continues) or info (status). The logfile itself remains unchanged.</p><p>The file name will automatically be extended by a string '_YYMMDD' carrying the current date. Default is an empty option field, meaning that no structured logfile is written. <i>[key: logFileStructured]</i></p>"));
+  _logFileStructuredLineEdit->setWhatsThis(tr("<p>In addition to the logfile, BNC can write the same records as a structured logfile for log processing tools: one record per line, either JSON (JSON Lines) or logfmt (key=value pairs separated by blanks). Each record carries the time in UTC ('time', ISO 8601 with 'Z'), for records of a data epoch its GPS Time ('epoch'), a level (debug, info, warning, error), the component (e.g. stream, ppp, cmb), the event (e.g. ppp_position, stream_outage_begin), the mountpoint ('mp') of the stream or the PPP station if known, the event's fields, the text of the classic logfile ('msg') and the record version ('v').</p><p>Messages without own event are written with event 'message' and the component of their origin; their level is error (a function does not work), warning (data or configuration problem, BNC continues) or info (status). The logfile itself remains unchanged.</p><p>The structured logfile is one file without date in its name, always appended, to be rotated by an external tool like logrotate (BNC continues with a new file if it is moved or removed). Default is an empty option field, meaning that no structured logfile is written. <i>[key: logFileStructured]</i></p>"));
   _logFormatStructuredComboBox->setWhatsThis(tr("<p>Select the format of the structured logfile: 'json' for one JSON object per line (JSON Lines), 'logfmt' for key=value pairs. Default is 'json'. <i>[key: logFormatStructured]</i></p>"));
   _logLevelStructuredComboBox->setWhatsThis(tr("<p>Select the minimum level of the records written into the structured logfile: 'debug' writes all records (debug records exist only in BNC versions built with the BNC_DEBUG_* defines), 'info' leaves out the debug records, 'warning' writes warnings and errors only, 'error' errors only. The logfile is not affected. Default is 'debug'. <i>[key: logLevelStructured]</i></p>"));
Index: trunk/BNC/src/pppRun.cpp
===================================================================
--- trunk/BNC/src/pppRun.cpp	(revision 11186)
+++ trunk/BNC/src/pppRun.cpp	(revision 11187)
@@ -465,12 +465,13 @@
       }
       if (output._error) {
-        emit newLogRecord(t_logRecord(t_logRecord::warning, "ppp", "ppp_epoch_failed",
-                                      staID, QByteArray(log.str().c_str())), true);
+        t_logRecord rec(t_logRecord::warning, "ppp", "ppp_epoch_failed", staID,
+                        QByteArray(log.str().c_str()));
+        rec.setEpoch(output._epoTime);
+        emit newLogRecord(rec, true);
       }
       else {
         t_logRecord rec(t_logRecord::info, "ppp", "ppp_position", staID,
                         QByteArray(log.str().c_str()));
-        rec.add("epoch", QByteArray((output._epoTime.datestr() + 'T' +
-                                     output._epoTime.timestr(3)).c_str()))
+        rec.setEpoch(output._epoTime)
            .add("x", output._xyzRover[0], 4)
            .add("y", output._xyzRover[1], 4)
Index: trunk/BNC/tests/README.md
===================================================================
--- trunk/BNC/tests/README.md	(revision 11186)
+++ trunk/BNC/tests/README.md	(revision 11187)
@@ -33,5 +33,5 @@
 | `tools/net_check.py` | UDP/RTP sender filter and upload status checks on loopback (not part of `run_tests.py`) |
 | `tools/cred_check.py` | credentials files (`~/.netrc`, BNC format) for download and upload (not part of `run_tests.py`) |
-| `tools/logcheck.py` | structured logfile: JSON/logfmt syntax, both formats equal, `time` = `gpst` - leap seconds, `msg` = classic logfile |
+| `tools/logcheck.py` | structured logfile: JSON/logfmt syntax, both formats equal, `time` = classic GPS time stamp - leap seconds, optional `epoch`, `msg` = classic logfile |
 | `work/` | scratch output, not versioned |
 
Index: trunk/BNC/tests/cases/log_structured/case.json
===================================================================
--- trunk/BNC/tests/cases/log_structured/case.json	(revision 11186)
+++ trunk/BNC/tests/cases/log_structured/case.json	(revision 11187)
@@ -24,9 +24,9 @@
                      "-key", "logFormatStructured", "logfmt"]},
            {"dir": "chk", "tool": ["logcheck.py", "Output/PPPQuickStart.log_251117",
-                                   "Output/PPPQuickStart.jsonl_251117",
-                                   "lf/Output/PPPQuickStart.logfmt_251117"]}],
+                                   "Output/PPPQuickStart.jsonl",
+                                   "lf/Output/PPPQuickStart.logfmt"]}],
   "outputs": [
-    {"glob": "Output/PPPQuickStart.jsonl_251117", "name": "PPPQuickStart.jsonl"},
-    {"glob": "lf/Output/PPPQuickStart.logfmt_251117", "name": "PPPQuickStart.logfmt"},
+    {"glob": "Output/PPPQuickStart.jsonl", "name": "PPPQuickStart.jsonl"},
+    {"glob": "lf/Output/PPPQuickStart.logfmt", "name": "PPPQuickStart.logfmt"},
     {"glob": "chk/stdout.txt", "name": "logcheck.txt"}
   ]
Index: trunk/BNC/tests/tools/logcheck.py
===================================================================
--- trunk/BNC/tests/tools/logcheck.py	(revision 11186)
+++ trunk/BNC/tests/tools/logcheck.py	(revision 11187)
@@ -6,9 +6,11 @@
 Checks that every line of the JSON file is a JSON object and every line of the
 logfmt file a sequence of key=value pairs, that both carry the same records,
-that the records have the mandatory keys in the documented order, that 'time'
-(UTC) is 'gpst' minus the GPS-UTC leap seconds and that the 'msg' of the
-records equals the text of the classic logfile line by line (classic lines
-without their "yy-mm-dd hh:mm:ss " prefix; the start line is skipped, it goes
-to the file of the current date). Prints a summary of the records per level,
+that the records have the mandatory keys in the documented order (optional
+'epoch' after 'time', GPS Time without 'Z'), that the 'msg' of the records
+(for RTCM scan message types: 'mp', 'message_type', 'size') equals the text of
+the classic logfile line by line (classic lines without
+their "yy-mm-dd hh:mm:ss " prefix; the start line is skipped, it goes to the
+file of the current date) and that 'time' (UTC) is the GPS Time stamp of the
+classic line minus the GPS-UTC leap seconds. Prints a summary of the records per level,
 component and event; exit code 1 on any error.
 """
@@ -20,5 +22,5 @@
 import sys
 
-HEAD = ["time", "gpst", "level", "component", "event"]
+HEAD = ["time", "level", "component", "event"]
 LEVELS = {"info", "warning", "error"}
 LEAP_GPS_UTC = 18          # valid since 2017-01-01
@@ -68,11 +70,28 @@
 
 
+def classic_text(r):
+    """Text of the classic logfile line of a record: 'msg', except for the
+    message types of the RTCM scan, which carry the short text 'Received message'
+    and the details in their fields."""
+    if r.get("event") == "stream_content" and "message_type" in r:
+        if r["msg"] != "Received message":
+            return "unexpected msg %r" % r["msg"]
+        size = " (size %d)" % r["size"] if "size" in r else " "
+        return "%s: Received message type %d%s" % (r["mp"], r["message_type"], size)
+    return r.get("msg")
+
+
 def main():
     errors = []
-    classic = []
+    classic, stamps = [], []
     for line in open(sys.argv[1], encoding="latin-1", newline="").read().split("\r\n"):
         if not line or "========== Start BNC" in line:
             continue
-        classic.append(line[18:] if re.match(r"\d\d-\d\d-\d\d \d\d:\d\d:\d\d ", line) else line)
+        if re.match(r"\d\d-\d\d-\d\d \d\d:\d\d:\d\d ", line):
+            classic.append(line[18:])
+            stamps.append(datetime.datetime.strptime(line[:17], "%y-%m-%d %H:%M:%S"))
+        else:
+            classic.append(line)
+            stamps.append(None)
 
     recs = []
@@ -92,5 +111,8 @@
             errors.append("json %d records, logfmt %d" % (len(recs), len(lf)))
         for k, (a, b) in enumerate(zip(recs, lf), 1):
-            if list(a.keys()) != list(b.keys()) or any(a[x] != b[x] for x in a):
+            # the start line carries the wall clock time of each run
+            start = "========== Start BNC" in a.get("msg", "")
+            if list(a.keys()) != list(b.keys()) or any(a[x] != b[x] for x in a
+                                                        if not (start and x == "time")):
                 errors.append("record %d differs between json and logfmt" % k)
 
@@ -98,16 +120,23 @@
     for k, r in enumerate(recs, 1):
         keys = list(r.keys())
-        if keys[:5] != HEAD or keys[-2:] != ["msg", "v"]:
+        if keys[1:2] == ["epoch"]:
+            try:
+                datetime.datetime.strptime(r["epoch"], "%Y-%m-%dT%H:%M:%S.%f")
+            except ValueError:
+                errors.append("record %d: epoch %s" % (k, r["epoch"]))
+            keys = keys[:1] + keys[2:]
+        if keys[:4] != HEAD or keys[-2:] != ["msg", "v"]:
             errors.append("record %d: keys %s" % (k, keys))
             continue
         if r["level"] not in LEVELS:
             errors.append("record %d: level %s" % (k, r["level"]))
-        utc = datetime.datetime.strptime(r["time"], "%Y-%m-%dT%H:%M:%S.%fZ")
-        gps = datetime.datetime.strptime(r["gpst"], "%Y-%m-%dT%H:%M:%S.%f")
-        if (gps - utc).total_seconds() != LEAP_GPS_UTC:
-            errors.append("record %d: time %s gpst %s" % (k, r["time"], r["gpst"]))
         count[(r["level"], r["component"], r["event"])] += 1
 
-    msgs = [r.get("msg") for r in recs if "========== Start BNC" not in r.get("msg", "")]
+    body = [r for r in recs if "========== Start BNC" not in r.get("msg", "")]
+    msgs = [classic_text(r) for r in body]
+    for k, (r, st) in enumerate(zip(body, stamps), 1):
+        utc = datetime.datetime.strptime(r["time"], "%Y-%m-%dT%H:%M:%S.%fZ")
+        if st is not None and (st - utc.replace(microsecond=0)).total_seconds() != LEAP_GPS_UTC:
+            errors.append("record %d: time %s, classic %s" % (k, r["time"], st))
     if msgs != classic:
         for k, (a, b) in enumerate(zip(msgs, classic), 1):
