- fixes in logging + allow ICENetworkAddress to be logged in short form

This commit is contained in:
Dmytro Bogovych 2024-01-15 13:18:59 +03:00
parent 69374d2973
commit 37471d56ff
3 changed files with 15 additions and 2 deletions

View File

@ -515,6 +515,18 @@ std::string NetworkAddress::toStdString() const
return temp; return temp;
} }
std::string NetworkAddress::toBriefStdString() const
{
if (!mInitialized)
return "";
char temp[128];
sprintf(temp, "%s:%u", ip().c_str(), (unsigned int)port());
return temp;
}
#ifdef WIN32 #ifdef WIN32
std::wstring NetworkAddress::toStdWString() const std::wstring NetworkAddress::toStdWString() const
{ {

View File

@ -61,6 +61,7 @@ namespace ice
unsigned short port() const; unsigned short port() const;
std::string toStdString() const; std::string toStdString() const;
std::string toBriefStdString() const;
#ifdef WIN32 #ifdef WIN32
std::wstring toStdWString() const; std::wstring toStdWString() const;
#endif #endif

View File

@ -211,8 +211,8 @@ Logger::endLine()
struct tm current_time = *gmtime(&unix_timestamp); struct tm current_time = *gmtime(&unix_timestamp);
char time_buffer[128]; strftime(time_buffer, sizeof(time_buffer), "%H:%M:%S", &current_time); char time_buffer[128]; strftime(time_buffer, sizeof(time_buffer), "%H:%M:%S", &current_time);
result << time_buffer << ":" << (unix_timestamp_ms.count() % 1000 ) << "\t" << " | " << std::setw(8) << ThreadInfo::currentThread() << " | " << std::setw(30) result << time_buffer << ":" << (unix_timestamp_ms.count() % 1000 ) << "\t" << " | " << std::setw(8) << ThreadInfo::currentThread() << " | "
<< mFilename.c_str() << " | " << std::setw(4) << mLine << " | " << std::setw(12) << mSubsystem.c_str() << " | " << std::setw(40) << mFilename.c_str() << " | " << std::setw(4) << mLine << " | " << std::setw(12) << mSubsystem.c_str() << " | "
<< mStream->str().c_str(); << mStream->str().c_str();
std::string t = result.str(); std::string t = result.str();