Check if log deep is enabled before tr_logAddDeep (#1329)

Co-authored-by: Charles Kerr <charles@charleskerr.com>
This commit is contained in:
Pedro Scarapicchia Junior 2020-07-28 14:31:36 -03:00 committed by GitHub
parent 910944733e
commit 5be8bd50f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 6 deletions

View File

@ -347,8 +347,11 @@ struct tr_peer_socket tr_netOpenPeerSocket(tr_session* session, tr_address const
ret = tr_peer_socket_tcp_create(s);
}
tr_logAddDeep(__FILE__, __LINE__, NULL, "New OUTGOING connection %" PRIdMAX " (%s)", (intmax_t)s,
tr_peerIoAddrStr(addr, port));
if (tr_logGetDeepEnabled())
{
tr_logAddDeep(__FILE__, __LINE__, NULL, "New OUTGOING connection %" PRIdMAX " (%s)", (intmax_t)s,
tr_peerIoAddrStr(addr, port));
}
return ret;
}

View File

@ -173,8 +173,12 @@ static void accept_incoming_peer(evutil_socket_t fd, short what UNUSED, void* vs
if (clientSocket != TR_BAD_SOCKET)
{
tr_logAddDeep(__FILE__, __LINE__, NULL, "new incoming connection %" PRIdMAX " (%s)", (intmax_t)clientSocket,
tr_peerIoAddrStr(&clientAddr, clientPort));
if (tr_logGetDeepEnabled())
{
tr_logAddDeep(__FILE__, __LINE__, NULL, "new incoming connection %" PRIdMAX " (%s)", (intmax_t)clientSocket,
tr_peerIoAddrStr(&clientAddr, clientPort));
}
tr_peerMgrAddIncoming(session->peerMgr, &clientAddr, clientPort, tr_peer_socket_tcp_create(clientSocket));
}
}

View File

@ -110,7 +110,11 @@ static void saveCumulativeStats(tr_session const* session, tr_session_stats cons
tr_variantDictAddInt(&top, TR_KEY_uploaded_bytes, s->uploadedBytes);
filename = getFilename(session);
tr_logAddDeep(__FILE__, __LINE__, NULL, "Saving stats to \"%s\"", filename);
if (tr_logGetDeepEnabled())
{
tr_logAddDeep(__FILE__, __LINE__, NULL, "Saving stats to \"%s\"", filename);
}
tr_variantToFile(&top, TR_VARIANT_FMT_JSON, filename);
tr_free(filename);

View File

@ -305,7 +305,11 @@ void tr_eventClose(tr_session* session)
}
session->events->die = true;
tr_logAddDeep(__FILE__, __LINE__, NULL, "closing trevent pipe");
if (tr_logGetDeepEnabled())
{
tr_logAddDeep(__FILE__, __LINE__, NULL, "closing trevent pipe");
}
tr_netCloseSocket(session->events->fds[1]);
}