Changeset 11179 in ntrip for trunk/BNC/src/bnccore.cpp
- Timestamp:
- Nov 6, 2026, 4:05:20 PM (28 hours ago)
- File:
-
- 1 edited
-
trunk/BNC/src/bnccore.cpp (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/src/bnccore.cpp
r11136 r11179 71 71 _logFile = 0; 72 72 _logStream = 0; 73 _logFileStructured = 0; 74 _logFormatStructured = t_logRecord::json; 73 75 _rawFile = 0; 74 76 _caster = 0; … … 103 105 qRegisterMetaType< QVector<double> > ("QVector<double>"); 104 106 qRegisterMetaType<bncTime> ("bncTime"); 107 qRegisterMetaType<t_logRecord> ("t_logRecord"); 105 108 qRegisterMetaType<t_ephGPS> ("t_ephGPS"); 106 109 qRegisterMetaType<t_ephGlo> ("t_ephGlo"); … … 122 125 delete _logStream; _logStream = 0; 123 126 delete _logFile; _logFile = 0; 127 delete _logFileStructured; _logFileStructured = 0; 124 128 qDeleteAll(_ephFiles); 125 129 delete _serverEph; … … 144 148 return; 145 149 } 150 slotLogRecord(t_logRecord::fromMessage(msg), showOnScreen); 151 } 152 153 // Write a Program Message with structured fields (structured logfile); 154 // the classic logfile and the screen get the text rec._msg 155 //////////////////////////////////////////////////////////////////////////// 156 void t_bncCore::slotLogRecord(t_logRecord rec, bool showOnScreen) { 157 if (rec._msg.isEmpty()) { 158 return; 159 } 146 160 QMutexLocker locker(&_mutexMessage); 147 161 148 messagePrivate( msg);149 emit newMessage(msg, showOnScreen); 162 messagePrivate(rec); 163 emit newMessage(rec._msg, showOnScreen); 150 164 } 151 165 152 166 // Write a Program Message (private, no lock) 153 167 //////////////////////////////////////////////////////////////////////////// 154 void t_bncCore::messagePrivate(const QByteArray& msg) { 155 156 // First time resolve the log file name 157 // ------------------------------------ 158 QDate currDate = currentDateAndTimeGPS().date(); 168 void t_bncCore::messagePrivate(const t_logRecord& rec) { 169 170 // First time resolve the log file names 171 // ------------------------------------- 172 QDateTime currDateTime = currentDateAndTimeGPS(); 173 QDate currDate = currDateTime.date(); 159 174 if (_logFileFlag == 0 || _fileDate != currDate) { 160 175 delete _logStream; _logStream = 0; 161 176 delete _logFile; _logFile = 0; 177 delete _logFileStructured; _logFileStructured = 0; 162 178 _logFileFlag = 1; 179 _fileDate = currDate; 163 180 bncSettings settings; 181 bool append = (Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked); 164 182 QString logFileName = settings.value("logFile").toString(); 165 183 if ( !logFileName.isEmpty() ) { … … 167 185 _logFile = new QFile(logFileName + "_" + 168 186 currDate.toString("yyMMdd").toLatin1().data()); 169 _fileDate = currDate; 170 if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked) { 187 if (append) { 171 188 _logFile->open(QIODevice::WriteOnly | QIODevice::Append); 172 189 } … … 177 194 _logStream->setDevice(_logFile); 178 195 } 196 QString structName = settings.value("logFileStructured").toString(); 197 if ( !structName.isEmpty() ) { 198 expandEnvVar(structName); 199 _logFormatStructured = t_logRecord::formatFromString( 200 settings.value("logFormatStructured").toString()); 201 _logFileStructured = new QFile(structName + "_" + currDate.toString("yyMMdd")); 202 if (!_logFileStructured->open(append ? (QIODevice::WriteOnly | QIODevice::Append) 203 : QIODevice::WriteOnly)) { 204 delete _logFileStructured; _logFileStructured = 0; 205 } 206 } 179 207 } 180 208 181 209 if (_logStream) { 182 QByteArray msgLocal = msg; 183 if (msg.indexOf('\n') == 0) { 210 QByteArray msgLocal = rec._msg; 211 if (rec._msg.indexOf('\n') == 0) { 184 212 *_logStream << "\r\n"; 185 msgLocal = msg.mid(1); 186 } 187 *_logStream << curr entDateAndTimeGPS().toString("yy-MM-dd hh:mm:ss ").toLatin1().data();213 msgLocal = rec._msg.mid(1); 214 } 215 *_logStream << currDateTime.toString("yy-MM-dd hh:mm:ss ").toLatin1().data(); 188 216 *_logStream << msgLocal.data() << "\r\n"; 189 217 _logStream->flush(); 190 218 _logFile->flush(); 219 } 220 221 if (_logFileStructured) { 222 _logFileStructured->write(rec.encode(_logFormatStructured, currDateTime) + "\n"); 223 _logFileStructured->flush(); 191 224 } 192 225 } … … 199 232 #ifdef BNC_DEBUG_BCE 200 233 if (eph->checkState() == t_eph::unhealthy) { 201 messagePrivate(QString("%1: UNHEALTHY %2:%3") 234 messagePrivate(t_logRecord::fromMessage(QString("%1: UNHEALTHY %2:%3") 202 235 .arg(eph->receptStaID()) 203 236 .arg(eph->typeStr(eph->type(), eph->prn(), 99.0)) 204 .arg(eph->rinexDateStr(eph->TOC(), eph->prn(), 99.0)).toLatin1()); 237 .arg(eph->rinexDateStr(eph->TOC(), eph->prn(), 99.0)).toLatin1())); 205 238 } 206 239 if (eph->checkState() == t_eph::bad) { 207 messagePrivate(QString("%1: WRONG %2:%3") 240 messagePrivate(t_logRecord::fromMessage(QString("%1: WRONG %2:%3") 208 241 .arg(eph->receptStaID()) 209 242 .arg(eph->typeStr(eph->type(), eph->prn(), 99.0)) 210 .arg(eph->rinexDateStr(eph->TOC(), eph->prn(), 99.0)).toLatin1()); 243 .arg(eph->rinexDateStr(eph->TOC(), eph->prn(), 99.0)).toLatin1())); 211 244 } 212 245 if (eph->checkState() == t_eph::outdated) { 213 messagePrivate(QString("%1: OUTDATED %2:%3") 246 messagePrivate(t_logRecord::fromMessage(QString("%1: OUTDATED %2:%3") 214 247 .arg(eph->receptStaID()) 215 248 .arg(eph->typeStr(eph->type(), eph->prn(), 99.0)) 216 .arg(eph->rinexDateStr(eph->TOC(), eph->prn(), 99.0)).toLatin1()); 249 .arg(eph->rinexDateStr(eph->TOC(), eph->prn(), 99.0)).toLatin1())); 217 250 } 218 251 #endif
Note:
See TracChangeset
for help on using the changeset viewer.
