Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions framework/areg/base/GETypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@

#include <stddef.h>

//! The type defining ID. It is 64-bit in 64-bit systems.
typedef unsigned long id_type;

//! The digital value type of the pointer.
#ifdef BIT64

//! The type defining ID. It is 64-bit in 64-bit systems.
typedef uint64_t id_type;

#ifdef _UINTPTR_T_DEFINED
typedef uintptr_t ptr_type;
#else // !_UINTPTR_T_DEFINED
Expand All @@ -72,6 +72,9 @@ typedef unsigned long id_type;

#else // defined(BIT32)

//! The type defining ID. It is 64-bit in 64-bit systems.
typedef uint32_t id_type;

#ifdef _UINTPTR_T_DEFINED
typedef uintptr_t ptr_type;
#else // !_UINTPTR_T_DEFINED
Expand Down
2 changes: 1 addition & 1 deletion framework/areg/logging/IELogDatabaseEngine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class AREG_API IELogDatabaseEngine : public IEDatabaseEngine
* \brief Returns true if the database and the log tables are initialized,
* and ready to log messages.
**/
virtual bool tablesInitialized(void) const = 0;
virtual bool areTablesInitialized(void) const = 0;

/**
* \brief Called when logging message should be saved in the database.
Expand Down
6 changes: 3 additions & 3 deletions framework/areg/logging/NELogging.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,9 @@ namespace NELogging
**/
sLogMessage & operator = (const sLogMessage & src);

NELogging::eLogDataType logDataType; //!< The type of log message data.
NELogging::eLogMessageType logMsgType; //!< The type of the logging message.
NELogging::eLogPriority logMessagePrio; //!< The log message priority
NELogging::eLogDataType logDataType; //!< The type of log message data.
NELogging::eLogMessageType logMsgType; //!< The type of the logging message.
NELogging::eLogPriority logMessagePrio; //!< The log message priority
ITEM_ID logSource; //!< The ID of the source that generated logging message.
ITEM_ID logTarget; //!< The ID of the target to send logging message, valid only in case of TCP/IP logging.
ITEM_ID logCookie; //!< The cookie set by the networking service, i.e. the log collector. Valid only in case of TCP/IP logging.
Expand Down
140 changes: 87 additions & 53 deletions framework/aregextend/db/LogSqliteDatabase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,16 @@
* Include files.
************************************************************************/
#include "areg/base/GEGlobal.h"

#include "aregextend/db/SqliteDatabase.hpp"
#include "aregextend/db/SqliteStatement.hpp"
#include "areg/component/NEService.hpp"
#include "areg/logging/NELogging.hpp"
#include "areg/logging/IELogDatabaseEngine.hpp"
#include "areg/base/String.hpp"

#if 0
#include <vector>

enum eLogItemType
{
ItemUnknown = 0 //!< Unknown log item type
, ItemInstance //!< Log instance item
, ItemThread //!< Log thread item
, ItemScope //!< Log scope item
, ItemPriority //!< Log priority item
};

struct sLogItem
{
ITEM_ID itemId { 0 }; //<! The ID of the log item
String itemName{ }; //!< The name of the log item
};

struct sLogItemList
{
eLogItemType itemType{ ItemUnknown }; //!< The type of the log item
std::vector<sLogItem> itemList{ }; //!< The list of log items
};
#endif
//////////////////////////////////////////////////////////////////////////
// LogSqliteDatabase class declaration
//////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -150,7 +133,7 @@ class LogSqliteDatabase : public IELogDatabaseEngine
* \brief Returns true if the database and the log tables are initialized,
* and ready to log messages.
**/
virtual bool tablesInitialized(void) const override;
virtual bool areTablesInitialized(void) const override;

/**
* \brief Called when logging message should be saved in the database.
Expand Down Expand Up @@ -231,30 +214,89 @@ class LogSqliteDatabase : public IELogDatabaseEngine
//////////////////////////////////////////////////////////////////////////
// Attributes and operations
//////////////////////////////////////////////////////////////////////////
#if 0
std::vector<String> getLogInstanceNames(void) const;

std::vector<ITEM_ID> getLogInstances(void) const;
/**
* \brief Call to query and get list of names of connected instances from log database.
**/
std::vector<String> getLogInstanceNames(void);
void getLogInstanceNames(std::vector<String>& names);

std::vector<String> getLogThreadNames(void) const;
/**
* \brief Call to query and get list of IDs of connected instances from log database.
**/
std::vector<ITEM_ID> getLogInstances(void);
void getLogInstances(std::vector<ITEM_ID>& ids);

std::vector<ITEM_ID> getLogThreads(void) const;
/**
* \brief Call to query and get list of names of threads of the connected instances from log database.
**/
std::vector<String> getLogThreadNames(void);
void getLogThreadNames(std::vector<String>& names);

std::vector<String> getLogScopeNames(void) const;
/**
* \brief Call to query and get list of IDs of threads of the connected instances from log database.
**/
std::vector<ITEM_ID> getLogThreads(void);
void getLogThreads(std::vector<ITEM_ID>& ids);

std::vector<ITEM_ID> getLogScopes(void) const;
/**
* \brief Call to get the list of log priorities.
**/
std::vector<String> getPriorityNames(void);
void getPriorityNames(std::vector<String>& names);

std::vector<String> getPriorityNames(void) const;
/**
* \brief Call to query and get information of connected instances from log database.
* This query will receive list of all registered instances.
**/
std::vector< NEService::sServiceConnectedInstance> getLogInstanceInfos(void);
void getLogInstanceInfos(std::vector< NEService::sServiceConnectedInstance>& infos);

std::vector<NELogging::sScopeInfo> getLogInstScopes(ITEM_ID instId) const;
/**
* \brief Call to query and get information of log scopes of specified instance from log database.
* This query will receive list of all registered scopes.
* \param instID The ID of the instance.
**/
std::vector<NELogging::sScopeInfo> getLogInstScopes(ITEM_ID instId);
void getLogInstScopes(std::vector<NELogging::sScopeInfo>& scopes, ITEM_ID instId);

std::vector<SharedBuffer> getLodMessages(void) const;
/**
* \brief Call to get all log messages from log database.
**/
std::vector<SharedBuffer> getLogMessages(void);
void getLogMessages(std::vector<SharedBuffer>& messages);

std::vector<SharedBuffer> getLodInstMessages(ITEM_ID instId) const;
/**
* \brief Call to get log messages of the specified instance from log database.
* If `instId` is `NEService::COOKIE_ANY` it receives the list of all instances
* similar to the call to `getLogMessages()`.
* \param instId The ID of the instance to get log messages.
* If `NEService::COOKIE_ANY` it receives log messages of all instances.
**/
std::vector<SharedBuffer> getLogInstMessages(ITEM_ID instId = NEService::COOKIE_ANY);
void getLogInstMessages(std::vector<SharedBuffer>& messages, ITEM_ID instId = NEService::COOKIE_ANY);

std::vector<SharedBuffer> getLodScopeMessages(ITEM_ID instId, uint32_t scopeId) const;
/**
* \brief Call to get log messages of the specified scope from log database.
* If `scopeId` is `0` it receives the list of all scopes
* similar to the call to `getLogMessages()`.
* \param scopeId The ID of the scope to get log messages.
* If `0` it receives log messages of all scopes.
**/
std::vector<SharedBuffer> getLogScopeMessages(uint32_t scopeId = 0);
void getLogScopeMessages(std::vector<SharedBuffer>& messages, uint32_t scopeId = 0);

#endif
/**
* \brief Call to get log messages of the specified instance and log scope ID from log database.
* If `instId` is `NEService::COOKIE_ANY` and `scopeId` is `0`, it receives the list of all logs
* similar to the call to `getLogMessages()`.
* \param instId The ID of the instance to get log messages.
* If `NEService::COOKIE_ANY` it receives log messages of all instances.
* \param scopeId The ID of the scope to get log messages.
* If `0` it receives log messages of all scopes.
**/
std::vector<SharedBuffer> getLogMessages(ITEM_ID instId, uint32_t scopeId);
void getLogMessages(std::vector<SharedBuffer>& messages, ITEM_ID instId, uint32_t scopeId);

//////////////////////////////////////////////////////////////////////////
// Hidden methods
Expand All @@ -267,11 +309,6 @@ class LogSqliteDatabase : public IELogDatabaseEngine
**/
inline bool _open(const String& dbPath);

/**
* \brief Closes previously opened database and releases resources.
**/
inline void _close(void);

/**
* \brief In the opened database file, creates the tables required to save logs.
**/
Expand All @@ -287,29 +324,26 @@ class LogSqliteDatabase : public IELogDatabaseEngine
**/
inline void _initialize(void);

/**
* \brief Executes the SQL script. The database should be already opened and initialized.
**/
inline bool _execute(const char * sql);
inline void _copyLogMessage(SqliteStatement& stmt, SharedBuffer & buf);

//////////////////////////////////////////////////////////////////////////
// Member variables.
//////////////////////////////////////////////////////////////////////////
protected:
//!< The path to the SQLite database file.
String mDbPath;
SqliteDatabase mDatabase;

//!< The initial path to the SQLIte database file. The path may contain mask like timestamp.
String mDbInitPath;
//!< The statement to log messages in the database.
SqliteStatement mStmtLogs;

//!< The SQLite database object.
void * mDbObject;
//!< The initial path to the SQLIte database file. The path may contain mask like timestamp.
String mDbInitPath;

//!< Flag, indicating whether the database and data tables are initialized or not.
bool mIsInitialized;
bool mIsInitialized;

//!< Flag, indicating whether the database logging is enabled or not.
bool mDbLogEnabled;
bool mDbLogEnabled;

//////////////////////////////////////////////////////////////////////////
// Forbidden calls.
Expand All @@ -334,7 +368,7 @@ inline void LogSqliteDatabase::setDatabaseLoggingEnabled(bool enable)

inline const String& LogSqliteDatabase::getDatabasePath(void) const
{
return mDbPath;
return mDatabase.getPath();
}

inline const String& LogSqliteDatabase::getInitialDatabasePath(void) const
Expand Down
Loading
Loading