1818 * Include files.
1919 ************************************************************************/
2020#include " areg/base/GEGlobal.h"
21+
22+ #include " aregextend/db/SqliteDatabase.hpp"
23+ #include " aregextend/db/SqliteStatement.hpp"
24+ #include " areg/component/NEService.hpp"
25+ #include " areg/logging/NELogging.hpp"
2126#include " areg/logging/IELogDatabaseEngine.hpp"
2227#include " areg/base/String.hpp"
2328
24- #if 0
2529#include < vector>
2630
27- enum eLogItemType
28- {
29- ItemUnknown = 0 //!< Unknown log item type
30- , ItemInstance //!< Log instance item
31- , ItemThread //!< Log thread item
32- , ItemScope //!< Log scope item
33- , ItemPriority //!< Log priority item
34- };
35-
36- struct sLogItem
37- {
38- ITEM_ID itemId { 0 }; //<! The ID of the log item
39- String itemName{ }; //!< The name of the log item
40- };
41-
42- struct sLogItemList
43- {
44- eLogItemType itemType{ ItemUnknown }; //!< The type of the log item
45- std::vector<sLogItem> itemList{ }; //!< The list of log items
46- };
47- #endif
4831// ////////////////////////////////////////////////////////////////////////
4932// LogSqliteDatabase class declaration
5033// ////////////////////////////////////////////////////////////////////////
@@ -150,7 +133,7 @@ class LogSqliteDatabase : public IELogDatabaseEngine
150133 * \brief Returns true if the database and the log tables are initialized,
151134 * and ready to log messages.
152135 **/
153- virtual bool tablesInitialized (void ) const override ;
136+ virtual bool areTablesInitialized (void ) const override ;
154137
155138 /* *
156139 * \brief Called when logging message should be saved in the database.
@@ -231,30 +214,89 @@ class LogSqliteDatabase : public IELogDatabaseEngine
231214// ////////////////////////////////////////////////////////////////////////
232215// Attributes and operations
233216// ////////////////////////////////////////////////////////////////////////
234- #if 0
235- std::vector<String> getLogInstanceNames(void) const;
236217
237- std::vector<ITEM_ID> getLogInstances(void) const;
218+ /* *
219+ * \brief Call to query and get list of names of connected instances from log database.
220+ **/
221+ std::vector<String> getLogInstanceNames (void );
222+ void getLogInstanceNames (std::vector<String>& names);
238223
239- std::vector<String> getLogThreadNames(void) const;
224+ /* *
225+ * \brief Call to query and get list of IDs of connected instances from log database.
226+ **/
227+ std::vector<ITEM_ID> getLogInstances (void );
228+ void getLogInstances (std::vector<ITEM_ID>& ids);
240229
241- std::vector<ITEM_ID> getLogThreads(void) const;
230+ /* *
231+ * \brief Call to query and get list of names of threads of the connected instances from log database.
232+ **/
233+ std::vector<String> getLogThreadNames (void );
234+ void getLogThreadNames (std::vector<String>& names);
242235
243- std::vector<String> getLogScopeNames(void) const;
236+ /* *
237+ * \brief Call to query and get list of IDs of threads of the connected instances from log database.
238+ **/
239+ std::vector<ITEM_ID> getLogThreads (void );
240+ void getLogThreads (std::vector<ITEM_ID>& ids);
244241
245- std::vector<ITEM_ID> getLogScopes(void) const;
242+ /* *
243+ * \brief Call to get the list of log priorities.
244+ **/
245+ std::vector<String> getPriorityNames (void );
246+ void getPriorityNames (std::vector<String>& names);
246247
247- std::vector<String> getPriorityNames(void) const;
248+ /* *
249+ * \brief Call to query and get information of connected instances from log database.
250+ * This query will receive list of all registered instances.
251+ **/
252+ std::vector< NEService::sServiceConnectedInstance > getLogInstanceInfos (void );
253+ void getLogInstanceInfos (std::vector< NEService::sServiceConnectedInstance >& infos);
248254
249- std::vector<NELogging::sScopeInfo> getLogInstScopes(ITEM_ID instId) const;
255+ /* *
256+ * \brief Call to query and get information of log scopes of specified instance from log database.
257+ * This query will receive list of all registered scopes.
258+ * \param instID The ID of the instance.
259+ **/
260+ std::vector<NELogging::sScopeInfo > getLogInstScopes (ITEM_ID instId);
261+ void getLogInstScopes (std::vector<NELogging::sScopeInfo >& scopes, ITEM_ID instId);
250262
251- std::vector<SharedBuffer> getLodMessages(void) const;
263+ /* *
264+ * \brief Call to get all log messages from log database.
265+ **/
266+ std::vector<SharedBuffer> getLogMessages (void );
267+ void getLogMessages (std::vector<SharedBuffer>& messages);
252268
253- std::vector<SharedBuffer> getLodInstMessages(ITEM_ID instId) const;
269+ /* *
270+ * \brief Call to get log messages of the specified instance from log database.
271+ * If `instId` is `NEService::COOKIE_ANY` it receives the list of all instances
272+ * similar to the call to `getLogMessages()`.
273+ * \param instId The ID of the instance to get log messages.
274+ * If `NEService::COOKIE_ANY` it receives log messages of all instances.
275+ **/
276+ std::vector<SharedBuffer> getLogInstMessages (ITEM_ID instId = NEService::COOKIE_ANY);
277+ void getLogInstMessages (std::vector<SharedBuffer>& messages, ITEM_ID instId = NEService::COOKIE_ANY);
254278
255- std::vector<SharedBuffer> getLodScopeMessages(ITEM_ID instId, uint32_t scopeId) const;
279+ /* *
280+ * \brief Call to get log messages of the specified scope from log database.
281+ * If `scopeId` is `0` it receives the list of all scopes
282+ * similar to the call to `getLogMessages()`.
283+ * \param scopeId The ID of the scope to get log messages.
284+ * If `0` it receives log messages of all scopes.
285+ **/
286+ std::vector<SharedBuffer> getLogScopeMessages (uint32_t scopeId = 0 );
287+ void getLogScopeMessages (std::vector<SharedBuffer>& messages, uint32_t scopeId = 0 );
256288
257- #endif
289+ /* *
290+ * \brief Call to get log messages of the specified instance and log scope ID from log database.
291+ * If `instId` is `NEService::COOKIE_ANY` and `scopeId` is `0`, it receives the list of all logs
292+ * similar to the call to `getLogMessages()`.
293+ * \param instId The ID of the instance to get log messages.
294+ * If `NEService::COOKIE_ANY` it receives log messages of all instances.
295+ * \param scopeId The ID of the scope to get log messages.
296+ * If `0` it receives log messages of all scopes.
297+ **/
298+ std::vector<SharedBuffer> getLogMessages (ITEM_ID instId, uint32_t scopeId);
299+ void getLogMessages (std::vector<SharedBuffer>& messages, ITEM_ID instId, uint32_t scopeId);
258300
259301// ////////////////////////////////////////////////////////////////////////
260302// Hidden methods
@@ -267,11 +309,6 @@ class LogSqliteDatabase : public IELogDatabaseEngine
267309 **/
268310 inline bool _open (const String& dbPath);
269311
270- /* *
271- * \brief Closes previously opened database and releases resources.
272- **/
273- inline void _close (void );
274-
275312 /* *
276313 * \brief In the opened database file, creates the tables required to save logs.
277314 **/
@@ -287,29 +324,26 @@ class LogSqliteDatabase : public IELogDatabaseEngine
287324 **/
288325 inline void _initialize (void );
289326
290- /* *
291- * \brief Executes the SQL script. The database should be already opened and initialized.
292- **/
293- inline bool _execute (const char * sql);
327+ inline void _copyLogMessage (SqliteStatement& stmt, SharedBuffer & buf);
294328
295329// ////////////////////////////////////////////////////////////////////////
296330// Member variables.
297331// ////////////////////////////////////////////////////////////////////////
298332protected:
299333 // !< The path to the SQLite database file.
300- String mDbPath ;
334+ SqliteDatabase mDatabase ;
301335
302- // !< The initial path to the SQLIte database file. The path may contain mask like timestamp .
303- String mDbInitPath ;
336+ // !< The statement to log messages in the database .
337+ SqliteStatement mStmtLogs ;
304338
305- // !< The SQLite database object .
306- void * mDbObject ;
339+ // !< The initial path to the SQLIte database file. The path may contain mask like timestamp .
340+ String mDbInitPath ;
307341
308342 // !< Flag, indicating whether the database and data tables are initialized or not.
309- bool mIsInitialized ;
343+ bool mIsInitialized ;
310344
311345 // !< Flag, indicating whether the database logging is enabled or not.
312- bool mDbLogEnabled ;
346+ bool mDbLogEnabled ;
313347
314348// ////////////////////////////////////////////////////////////////////////
315349// Forbidden calls.
@@ -334,7 +368,7 @@ inline void LogSqliteDatabase::setDatabaseLoggingEnabled(bool enable)
334368
335369inline const String& LogSqliteDatabase::getDatabasePath (void ) const
336370{
337- return mDbPath ;
371+ return mDatabase . getPath () ;
338372}
339373
340374inline const String& LogSqliteDatabase::getInitialDatabasePath (void ) const
0 commit comments