mirror of
https://github.com/gabime/spdlog.git
synced 2025-01-26 15:39:03 +08:00
Remove is_init() check on each log call
This commit is contained in:
parent
497fa60f57
commit
2e66a27081
@ -77,11 +77,6 @@ public:
|
|||||||
init_winsock_();
|
init_winsock_();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_init())
|
|
||||||
{
|
|
||||||
close();
|
|
||||||
}
|
|
||||||
|
|
||||||
addr_.sin_family = PF_INET;
|
addr_.sin_family = PF_INET;
|
||||||
addr_.sin_port = htons(port);
|
addr_.sin_port = htons(port);
|
||||||
addr_.sin_addr.s_addr = INADDR_ANY;
|
addr_.sin_addr.s_addr = INADDR_ANY;
|
||||||
@ -108,7 +103,10 @@ public:
|
|||||||
|
|
||||||
void close()
|
void close()
|
||||||
{
|
{
|
||||||
::closesocket(socket_);
|
if (socket_ != -1)
|
||||||
|
{
|
||||||
|
::closesocket(socket_);
|
||||||
|
}
|
||||||
socket_ = INVALID_SOCKET;
|
socket_ = INVALID_SOCKET;
|
||||||
WSACleanup();
|
WSACleanup();
|
||||||
}
|
}
|
||||||
|
@ -52,14 +52,9 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_init() const
|
|
||||||
{
|
|
||||||
return socket_ != -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void close()
|
void close()
|
||||||
{
|
{
|
||||||
if (is_init())
|
if (socket_ != -1)
|
||||||
{
|
{
|
||||||
::close(socket_);
|
::close(socket_);
|
||||||
socket_ = -1;
|
socket_ = -1;
|
||||||
|
@ -53,10 +53,6 @@ protected:
|
|||||||
{
|
{
|
||||||
spdlog::memory_buf_t formatted;
|
spdlog::memory_buf_t formatted;
|
||||||
spdlog::sinks::base_sink<Mutex>::formatter_->format(msg, formatted);
|
spdlog::sinks::base_sink<Mutex>::formatter_->format(msg, formatted);
|
||||||
if (!client_.is_init())
|
|
||||||
{
|
|
||||||
client_.init(config_.server_host, config_.server_port);
|
|
||||||
}
|
|
||||||
client_.send(formatted.data(), formatted.size());
|
client_.send(formatted.data(), formatted.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user