Browse Source

* sane log messages: util.cpp

pull/317/head
hagen 9 years ago
parent
commit
1cb08fdecc
  1. 46
      util.cpp

46
util.cpp

@ -166,7 +166,7 @@ namespace filesystem
// Create data directory // Create data directory
if (!boost::filesystem::create_directory( path )) if (!boost::filesystem::create_directory( path ))
{ {
LogPrint("Failed to create data directory!"); LogPrint(eLogError, "FS: Failed to create data directory!");
path = ""; path = "";
return path; return path;
} }
@ -291,13 +291,13 @@ namespace http
} }
else else
{ {
LogPrint ("Can't connect to ", address); LogPrint (eLogError, "HTTPClient: Can't connect to ", address);
return ""; return "";
} }
} }
catch (std::exception& ex) catch (std::exception& ex)
{ {
LogPrint ("Failed to download ", address, " : ", ex.what ()); LogPrint (eLogError, "HTTPClient: runtime exception: ", ex.what ());
return ""; return "";
} }
} }
@ -334,7 +334,7 @@ namespace http
} }
else else
{ {
LogPrint ("HTTP response ", status); LogPrint (eLogError, "HTTPClient: error, server responds ", status);
return ""; return "";
} }
} }
@ -399,19 +399,19 @@ namespace http
} }
else else
{ {
LogPrint("HTTP response ", status); LogPrint (eLogError, "HTTPClient: error, server responds ", status);
return status; return status;
} }
} }
else else
{ {
LogPrint("Can't connect to proxy"); LogPrint(eLogError, "HTTPClient: Can't connect to proxy");
return 408; return 408;
} }
} }
catch (std::exception& ex) catch (std::exception& ex)
{ {
LogPrint("Failed to download ", address, " : ", ex.what()); LogPrint(eLogError, "HTTPClient: runtime exception: ", ex.what());
return 408; return 408;
} }
} }
@ -515,7 +515,7 @@ namespace net
ifaddrs* ifaddr, *ifa = nullptr; ifaddrs* ifaddr, *ifa = nullptr;
if(getifaddrs(&ifaddr) == -1) if(getifaddrs(&ifaddr) == -1)
{ {
LogPrint(eLogError, "Can't excute getifaddrs"); LogPrint(eLogError, "NetIface: Can't call getifaddrs(): ", strerror(errno));
return fallback; return fallback;
} }
@ -551,14 +551,14 @@ namespace net
if(ioctl(fd, SIOCGIFMTU, &ifr) >= 0) if(ioctl(fd, SIOCGIFMTU, &ifr) >= 0)
mtu = ifr.ifr_mtu; // MTU mtu = ifr.ifr_mtu; // MTU
else else
LogPrint (eLogError, "Failed to run ioctl"); LogPrint (eLogError, "NetIface: Failed to run ioctl: ", strerror(errno));
close(fd); close(fd);
} }
else else
LogPrint(eLogError, "Failed to create datagram socket"); LogPrint(eLogError, "NetIface: Failed to create datagram socket");
} }
else else
LogPrint(eLogWarning, "Interface for local address", localAddress.to_string(), " not found"); LogPrint(eLogWarning, "NetIface: interface for local address", localAddress.to_string(), " not found");
freeifaddrs(ifaddr); freeifaddrs(ifaddr);
return mtu; return mtu;
@ -584,9 +584,7 @@ namespace net
); );
if(dwRetVal != NO_ERROR) { if(dwRetVal != NO_ERROR) {
LogPrint( LogPrint(eLogError, "NetIface: GetMTU(): enclosed GetAdaptersAddresses() call has failed");
eLogError, "GetMTU() has failed: enclosed GetAdaptersAddresses() call has failed"
);
FREE(pAddresses); FREE(pAddresses);
return fallback; return fallback;
} }
@ -597,9 +595,7 @@ namespace net
pUnicast = pCurrAddresses->FirstUnicastAddress; pUnicast = pCurrAddresses->FirstUnicastAddress;
if(pUnicast == nullptr) { if(pUnicast == nullptr) {
LogPrint( LogPrint(eLogError, "NetIface: GetMTU(): not a unicast ipv4 address, this is not supported");
eLogError, "GetMTU() has failed: not a unicast ipv4 address, this is not supported"
);
} }
for(int i = 0; pUnicast != nullptr; ++i) { for(int i = 0; pUnicast != nullptr; ++i) {
LPSOCKADDR lpAddr = pUnicast->Address.lpSockaddr; LPSOCKADDR lpAddr = pUnicast->Address.lpSockaddr;
@ -614,7 +610,7 @@ namespace net
pCurrAddresses = pCurrAddresses->Next; pCurrAddresses = pCurrAddresses->Next;
} }
LogPrint(eLogError, "GetMTU() error: no usable unicast ipv4 addresses found"); LogPrint(eLogError, "NetIface: GetMTU(): no usable unicast ipv4 addresses found");
FREE(pAddresses); FREE(pAddresses);
return fallback; return fallback;
} }
@ -637,10 +633,7 @@ namespace net
); );
if(dwRetVal != NO_ERROR) { if(dwRetVal != NO_ERROR) {
LogPrint( LogPrint(eLogError, "NetIface: GetMTU(): enclosed GetAdaptersAddresses() call has failed");
eLogError,
"GetMTU() has failed: enclosed GetAdaptersAddresses() call has failed"
);
FREE(pAddresses); FREE(pAddresses);
return fallback; return fallback;
} }
@ -651,10 +644,7 @@ namespace net
PIP_ADAPTER_UNICAST_ADDRESS firstUnicastAddress = pCurrAddresses->FirstUnicastAddress; PIP_ADAPTER_UNICAST_ADDRESS firstUnicastAddress = pCurrAddresses->FirstUnicastAddress;
pUnicast = pCurrAddresses->FirstUnicastAddress; pUnicast = pCurrAddresses->FirstUnicastAddress;
if(pUnicast == nullptr) { if(pUnicast == nullptr) {
LogPrint( LogPrint(eLogError, "NetIface: GetMTU(): not a unicast ipv6 address, this is not supported");
eLogError,
"GetMTU() has failed: not a unicast ipv6 address, this is not supported"
);
} }
for(int i = 0; pUnicast != nullptr; ++i) { for(int i = 0; pUnicast != nullptr; ++i) {
LPSOCKADDR lpAddr = pUnicast->Address.lpSockaddr; LPSOCKADDR lpAddr = pUnicast->Address.lpSockaddr;
@ -678,7 +668,7 @@ namespace net
pCurrAddresses = pCurrAddresses->Next; pCurrAddresses = pCurrAddresses->Next;
} }
LogPrint(eLogError, "GetMTU() error: no usable unicast ipv6 addresses found"); LogPrint(eLogError, "NetIface: GetMTU(): no usable unicast ipv6 addresses found");
FREE(pAddresses); FREE(pAddresses);
return fallback; return fallback;
} }
@ -701,7 +691,7 @@ namespace net
inet_pton(AF_INET6, localAddressUniversal.c_str(), &(inputAddress.sin6_addr)); inet_pton(AF_INET6, localAddressUniversal.c_str(), &(inputAddress.sin6_addr));
return GetMTUWindowsIpv6(inputAddress, fallback); return GetMTUWindowsIpv6(inputAddress, fallback);
} else { } else {
LogPrint(eLogError, "GetMTU() has failed: address family is not supported"); LogPrint(eLogError, "NetIface: GetMTU(): address family is not supported");
return fallback; return fallback;
} }

Loading…
Cancel
Save