mirror of
https://github.com/gabime/spdlog.git
synced 2025-01-12 17:00:25 +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_();
|
||||
}
|
||||
|
||||
if (is_init())
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
addr_.sin_family = PF_INET;
|
||||
addr_.sin_port = htons(port);
|
||||
addr_.sin_addr.s_addr = INADDR_ANY;
|
||||
@ -107,8 +102,11 @@ public:
|
||||
}
|
||||
|
||||
void close()
|
||||
{
|
||||
if (socket_ != -1)
|
||||
{
|
||||
::closesocket(socket_);
|
||||
}
|
||||
socket_ = INVALID_SOCKET;
|
||||
WSACleanup();
|
||||
}
|
||||
|
@ -52,14 +52,9 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
bool is_init() const
|
||||
{
|
||||
return socket_ != -1;
|
||||
}
|
||||
|
||||
void close()
|
||||
{
|
||||
if (is_init())
|
||||
if (socket_ != -1)
|
||||
{
|
||||
::close(socket_);
|
||||
socket_ = -1;
|
||||
|
@ -53,10 +53,6 @@ protected:
|
||||
{
|
||||
spdlog::memory_buf_t 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());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user