@@ -87,8 +87,7 @@ void ObserverMessageProcessor::notifyLogRegisterScopes(const RemoteMessage& msgR
8787 sLogScope & entry{ scopes[i] };
8888 entry.lsId = scope.getScopeId ();
8989 entry.lsPrio = scope.getPriority ();
90- NEString::copyString (entry.lsName , static_cast <NEString::CharCount>(LENGTH_SCOPE), scope.getScopeName ().getString (), scope.getScopeName ().getLength ());
91-
90+ NEMemory::memCopy (entry.lsName , LENGTH_SCOPE, scope.getScopeName ().getString (), scope.getScopeName ().getLength () + 1 );
9291 mLoggerClient .mLogDatabase .logScopeActivate (scope.getScopeName (), scope.getScopeId (), scope.getPriority (), cookie, now);
9392 }
9493
@@ -138,7 +137,7 @@ void ObserverMessageProcessor::notifyLogUpdateScopes(const RemoteMessage& msgRec
138137 sLogScope & entry{ scopes[i] };
139138 entry.lsId = scope.getScopeId ();
140139 entry.lsPrio = scope.getPriority ();
141- NEString::copyString (entry.lsName , static_cast <NEString::CharCount>( LENGTH_SCOPE) , scope.getScopeName ().getString (), scope.getScopeName ().getLength ());
140+ NEMemory::memCopy (entry.lsName , LENGTH_SCOPE, scope.getScopeName ().getString (), scope.getScopeName ().getLength () + 1 );
142141 mLoggerClient .mLogDatabase .logScopeActivate (scope.getScopeName (), scope.getScopeId (), scope.getPriority (), cookie, now);
143142 }
144143
@@ -197,8 +196,8 @@ void ObserverMessageProcessor::notifyLogMessage(const RemoteMessage& msgReceived
197196 msgLog.msgScopeId = static_cast <unsigned int >(msgRemote->logScopeId );
198197
199198 NEMemory::memCopy (msgLog.msgLogText , LENGTH_MESSAGE , msgRemote->logMessage , msgRemote->logMessageLen + 1 );
200- NEMemory::memCopy (msgLog.msgThread , LENGTH_NAME , msgRemote->logThread , msgRemote->logThreadLen + 1 );
201- NEMemory::memCopy (msgLog.msgModule , LENGTH_NAME , msgRemote->logModule , msgRemote->logModuleLen + 1 );
199+ NEMemory::memCopy (msgLog.msgThread , LENGTH_NAME , msgRemote->logThread , msgRemote->logThreadLen + 1 );
200+ NEMemory::memCopy (msgLog.msgModule , LENGTH_NAME , msgRemote->logModule , msgRemote->logModuleLen + 1 );
202201 }
203202 else if (mLoggerClient .mCallbacks ->evtLogMessageEx != nullptr )
204203 {
@@ -227,18 +226,31 @@ void ObserverMessageProcessor::_clientsConnected(const RemoteMessage& msgReceive
227226 FuncInstancesConnect callback{ nullptr };
228227 sLogInstance * listInstances{ nullptr };
229228 int size{ static_cast <int >(listConnected.getSize ()) };
229+ if (size == 0 )
230+ return ;
230231
231232 do
232233 {
233234 Lock lock (mLoggerClient .mLock );
234- if (LogObserverBase::_theLogObserver == nullptr )
235+ DateTime now (DateTime::getNow ());
236+
237+ if (LogObserverBase::_theLogObserver != nullptr )
235238 {
236- callback = mLoggerClient .mCallbacks != nullptr ? mLoggerClient .mCallbacks ->evtInstConnected : nullptr ;
237- }
239+ for (int i = 0 ; i < size; ++i)
240+ {
241+ const NEService::sServiceConnectedInstance & client{ listConnected[static_cast <uint32_t >(i)] };
242+ auto added = mLoggerClient .mInstances .addIfUnique (client.ciCookie , client, false );
243+ if (added.second )
244+ {
245+ mLoggerClient .mLogDatabase .logInstanceConnected (client, now);
246+ }
247+ }
238248
239- if (size > 0 )
249+ mLoggerClient .mLogDatabase .commit (true );
250+ }
251+ else
240252 {
241- DateTime now ( DateTime::getNow ()) ;
253+ callback = mLoggerClient . mCallbacks != nullptr ? mLoggerClient . mCallbacks -> evtInstConnected : nullptr ;
242254 listInstances = new sLogInstance [size];
243255
244256 for (int i = 0 ; i < size; ++i)
@@ -257,20 +269,13 @@ void ObserverMessageProcessor::_clientsConnected(const RemoteMessage& msgReceive
257269 inst.liBitness = static_cast <uint32_t >(client.ciBitness );
258270 inst.liCookie = client.ciCookie ;
259271 inst.liTimestamp = client.ciTimestamp ;
260- NEString::copyString (inst.liName
261- , static_cast <NEString::CharCount>(LENGTH_NAME)
262- , client.ciInstance .c_str ()
263- , static_cast <NEString::CharCount>(client.ciInstance .length ()));
264- NEString::copyString (inst.liLocation
265- , static_cast <NEString::CharCount>(LENGTH_LOCATION)
266- , client.ciLocation .c_str ()
267- , static_cast <NEString::CharCount>(client.ciLocation .length ()));
272+ NEMemory::memCopy (inst.liName , LENGTH_NAME , client.ciInstance .c_str (), static_cast <int >(client.ciInstance .length ()) + 1 );
273+ NEMemory::memCopy (inst.liLocation , LENGTH_LOCATION, client.ciLocation .c_str (), static_cast <int >(client.ciLocation .length ()) + 1 );
268274 }
269275 }
270276
271277 mLoggerClient .mLogDatabase .commit (true );
272278 }
273-
274279 } while (false );
275280
276281 if (LogObserverBase::_theLogObserver != nullptr )
0 commit comments