Changeset 11185 in ntrip for trunk/BNC/src/bnclog.cpp
- Timestamp:
- Nov 9, 2026, 12:15:48 PM (6 hours ago)
- File:
-
- 1 edited
-
trunk/BNC/src/bnclog.cpp (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/src/bnclog.cpp
r11179 r11185 24 24 namespace { 25 25 26 QMutex st ationMutex;27 QSet<QByteArray> st ations;26 QMutex streamMutex; 27 QSet<QByteArray> streams; 28 28 29 29 // text as UTF-8 (BNC's messages are Latin-1) … … 97 97 // Envelope of a plain text message 98 98 //////////////////////////////////////////////////////////////////////////// 99 t_logRecord t_logRecord::fromMessage(const QByteArray& msg) { 100 t_logRecord rec(info, "bnc", "message", "", msg);101 102 // st ation: first token of the text, if it is a known station name99 t_logRecord t_logRecord::fromMessage(const QByteArray& msg, const QByteArray& component) { 100 t_logRecord rec(info, component, "message", "", msg); 101 102 // stream: first token of the text, if it is a known stream or PPP station 103 103 int end = 0; 104 104 while (end < msg.size() && msg[end] != ':' && msg[end] != ' ' && msg[end] != '(') { … … 107 107 if (end > 0) { 108 108 QByteArray token = msg.left(end); 109 QMutexLocker locker(&st ationMutex);110 if (st ations.contains(token)) {111 rec._st ation= token;109 QMutexLocker locker(&streamMutex); 110 if (streams.contains(token)) { 111 rec._stream = token; 112 112 } 113 113 } … … 136 136 } 137 137 138 // Plain text message with an explicit level 139 //////////////////////////////////////////////////////////////////////////// 140 t_logRecord t_logRecord::message(e_level level, const QByteArray& msg, 141 const QByteArray& component) { 142 t_logRecord rec = fromMessage(msg, component); 143 rec._level = level; 144 return rec; 145 } 146 147 // Message of a BNC_DEBUG_* build 148 //////////////////////////////////////////////////////////////////////////// 149 t_logRecord t_logRecord::debugMessage(const QByteArray& component, const QByteArray& msg) { 150 t_logRecord rec = fromMessage(msg, component); 151 rec._level = debug; 152 return rec; 153 } 154 138 155 // 139 156 //////////////////////////////////////////////////////////////////////////// … … 196 213 const char* t_logRecord::levelString(e_level level) { 197 214 switch (level) { 215 case debug: return "debug"; 198 216 case warning: return "warning"; 199 217 case error: return "error"; … … 210 228 // 211 229 //////////////////////////////////////////////////////////////////////////// 212 void t_logRecord::registerStation(const QByteArray& station) { 213 if (station.isEmpty()) { 230 t_logRecord::e_level t_logRecord::levelFromString(const QString& str) { 231 QString ss = str.trimmed().toLower(); 232 if (ss == "info") return info; 233 if (ss == "warning") return warning; 234 if (ss == "error") return error; 235 return debug; 236 } 237 238 // 239 //////////////////////////////////////////////////////////////////////////// 240 void t_logRecord::registerStream(const QByteArray& stream) { 241 if (stream.isEmpty()) { 214 242 return; 215 243 } 216 QMutexLocker locker(&st ationMutex);217 st ations.insert(station);244 QMutexLocker locker(&streamMutex); 245 streams.insert(stream); 218 246 } 219 247 … … 242 270 put("component", _component, true); 243 271 put("event", _event, true); 244 if (!_st ation.isEmpty()) {245 put("st ation", _station, true);272 if (!_stream.isEmpty()) { 273 put("stream", _stream, true); 246 274 } 247 275 all += _fields;
Note:
See TracChangeset
for help on using the changeset viewer.
