Fixed the Logging system to actually be able to handle errors. Database is also fixed to use directories.

This commit is contained in:
2024-04-23 22:29:49 -07:00
parent 2734cc00fb
commit f030ac62ae
61 changed files with 884 additions and 602 deletions

View File

@@ -17,7 +17,7 @@ namespace ehs
Int_32 code = close(hdl);
if (code == -1)
EHS_LOG_INT("Error", 0, "Failed to close socket with error #" + Str_8::FromNum(errno) + ".");
EHS_LOG_INT(LogType::ERR, 0, "Failed to close socket with error #" + Str_8::FromNum(errno) + ".");
}
UDP::UDP()
@@ -39,7 +39,7 @@ namespace ehs
{
UInt_32 code = errno;
EHS_LOG_INT("Error", 1, "Failed to create socket with error #" + Str_8::FromNum(code) + ".");
EHS_LOG_INT(LogType::ERR, 1, "Failed to create socket with error #" + Str_8::FromNum(code) + ".");
return;
}
@@ -87,9 +87,9 @@ namespace ehs
if (!IsValid())
return;
Int_32 code = close(hdl);
const Int_32 code = close(hdl);
if (code == -1)
EHS_LOG_INT("Error", 0, "Failed to close socket with error #" + Str_8::FromNum(errno) + ".");
EHS_LOG_INT(LogType::ERR, 0, "Failed to close socket with error #" + Str_8::FromNum(errno) + ".");
hdl = EHS_INVALID_SOCKET;
@@ -126,7 +126,7 @@ namespace ehs
{
if (!IsValid())
{
EHS_LOG_INT("Error", 0, "Attempted to receive while socket is not initialized.");
EHS_LOG_INT(LogType::ERR, 0, "Attempted to receive while socket is not initialized.");
return 0;
}
@@ -142,7 +142,7 @@ namespace ehs
{
Release();
EHS_LOG_INT("Error", 1, "Failed to receive with error #" + Str_8::FromNum(code) + ".");
EHS_LOG_INT(LogType::ERR, 1, "Failed to receive with error #" + Str_8::FromNum(code) + ".");
}
return 0;
@@ -156,7 +156,7 @@ namespace ehs
{
Int_32 code = errno;
EHS_LOG_INT("Error", 2, "Failed to convert IPv6 address with error #" + Str_8::FromNum(code) + ".");
EHS_LOG_INT(LogType::ERR, 2, "Failed to convert IPv6 address with error #" + Str_8::FromNum(code) + ".");
return received;
}
@@ -173,7 +173,7 @@ namespace ehs
{
Int_32 code = errno;
EHS_LOG_INT("Error", 2, "Failed to convert IPv4 address with error #" + Str_8::FromNum(code) + ".");
EHS_LOG_INT(LogType::ERR, 2, "Failed to convert IPv4 address with error #" + Str_8::FromNum(code) + ".");
return received;
}
@@ -190,12 +190,12 @@ namespace ehs
{
if (!IsValid())
{
EHS_LOG_INT("Error", 0, "Attempted to toggle blocking while socket is not initialized.");
EHS_LOG_INT(LogType::ERR, 0, "Attempted to toggle blocking while socket is not initialized.");
return;
}
if (fcntl(hdl, F_SETFL, O_NONBLOCK, blocking) == -1)
EHS_LOG_INT("Error", 1, "Failed to toggle non-blocking mode with error #" + Str_8::FromNum(errno) + ".");
EHS_LOG_INT(LogType::ERR, 1, "Failed to toggle non-blocking mode with error #" + Str_8::FromNum(errno) + ".");
}
bool UDP::IsBlocking() const
@@ -219,14 +219,14 @@ namespace ehs
Int_32 code = inet_pton(AF_INET6, address, &result.sin6_addr);
if (!code)
{
EHS_LOG_INT("Error", 0, "The given address, \"" + address + "\" is not valid.");
EHS_LOG_INT(LogType::ERR, 0, "The given address, \"" + address + "\" is not valid.");
return;
}
else if (code == -1)
{
Int_32 dCode = errno;
EHS_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
EHS_LOG_INT(LogType::ERR, 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
return;
}
}
@@ -238,7 +238,7 @@ namespace ehs
int code = bind(hdl, (sockaddr*)&result, sizeof(sockaddr_in6));
if (code == -1)
{
EHS_LOG_INT("Error", 2, "Failed to bind socket with error #" + Str_8::FromNum(errno) + ".");
EHS_LOG_INT(LogType::ERR, 2, "Failed to bind socket with error #" + Str_8::FromNum(errno) + ".");
return;
}
}
@@ -254,14 +254,14 @@ namespace ehs
int code = inet_pton(AF_INET, address, &result.sin_addr);
if (!code)
{
EHS_LOG_INT("Error", 0, "The given address, \"" + address + "\" is not valid.");
EHS_LOG_INT(LogType::ERR, 0, "The given address, \"" + address + "\" is not valid.");
return;
}
else if (code == -1)
{
Int_32 dCode = errno;
EHS_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
EHS_LOG_INT(LogType::ERR, 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
return;
}
}
@@ -273,7 +273,7 @@ namespace ehs
int code = bind(hdl, (sockaddr*)&result, sizeof(sockaddr_in));
if (code == -1)
{
EHS_LOG_INT("Error", 2, "Failed to bind socket with error #" + Str_8::FromNum(errno) + ".");
EHS_LOG_INT(LogType::ERR, 2, "Failed to bind socket with error #" + Str_8::FromNum(errno) + ".");
return;
}
}
@@ -282,7 +282,7 @@ namespace ehs
{
if (!IsValid())
{
EHS_LOG_INT("Info", 0, "Attempted to send while socket is not initialized.");
EHS_LOG_INT(LogType::INFO, 0, "Attempted to send while socket is not initialized.");
return 0;
}
@@ -293,14 +293,14 @@ namespace ehs
Int_32 code = inet_pton(AF_INET6, address, &result.sin6_addr);
if (!code)
{
EHS_LOG_INT("Error", 1, "The given address, \"" + address + "\" is not valid.");
EHS_LOG_INT(LogType::ERR, 1, "The given address, \"" + address + "\" is not valid.");
return 0;
}
else if (code == -1)
{
Int_32 dCode = errno;
EHS_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
EHS_LOG_INT(LogType::ERR, 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
return 0;
}
@@ -309,7 +309,7 @@ namespace ehs
{
Int_32 dCode = errno;
EHS_LOG_INT("Error", 3, "Failed to send with error #" + Str_8::FromNum(dCode) + ".");
EHS_LOG_INT(LogType::ERR, 3, "Failed to send with error #" + Str_8::FromNum(dCode) + ".");
Release();
@@ -323,7 +323,7 @@ namespace ehs
{
if (!IsValid())
{
EHS_LOG_INT("Info", 0, "Attempted to send while socket is not initialized.");
EHS_LOG_INT(LogType::INFO, 0, "Attempted to send while socket is not initialized.");
return 0;
}
@@ -334,14 +334,14 @@ namespace ehs
int code = inet_pton(AF_INET, address, &result.sin_addr);
if (!code)
{
EHS_LOG_INT("Error", 1, "The given address, \"" + address + "\" is not valid.");
EHS_LOG_INT(LogType::ERR, 1, "The given address, \"" + address + "\" is not valid.");
return 0;
}
else if (code == -1)
{
Int_32 dCode = errno;
EHS_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
EHS_LOG_INT(LogType::ERR, 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
return 0;
}
@@ -350,7 +350,7 @@ namespace ehs
{
Int_32 dCode = errno;
EHS_LOG_INT("Error", 3, "Failed to send with error #" + Str_8::FromNum(dCode) + ".");
EHS_LOG_INT(LogType::ERR, 3, "Failed to send with error #" + Str_8::FromNum(dCode) + ".");
Release();