本文整理汇总了C++中LogLine函数的典型用法代码示例。如果您正苦于以下问题:C++ LogLine函数的具体用法?C++ LogLine怎么用?C++ LogLine使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LogLine函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: strerror
LogMessage::~LogMessage() {
// Finish constructing the message.
if (data_->GetError() != -1) {
data_->GetBuffer() << ": " << strerror(data_->GetError());
}
std::string msg(data_->ToString());
{
// Do the actual logging with the lock held.
lock_guard<mutex> lock(logging_lock);
if (msg.find('\n') == std::string::npos) {
LogLine(data_->GetFile(), data_->GetLineNumber(), data_->GetId(),
data_->GetSeverity(), msg.c_str());
} else {
msg += '\n';
size_t i = 0;
while (i < msg.size()) {
size_t nl = msg.find('\n', i);
msg[nl] = '\0';
LogLine(data_->GetFile(), data_->GetLineNumber(), data_->GetId(),
data_->GetSeverity(), &msg[i]);
i = nl + 1;
}
}
}
// Abort if necessary.
if (data_->GetSeverity() == FATAL) {
#ifdef __ANDROID__
android_set_abort_message(msg.c_str());
#endif
abort();
}
}
示例2: ASSERT
void CKadOperation::LogReport(UINT Flags, const wstring& ErrorMessage, const string& Error, const CVariant& Trace)
{
wstring Operation = L"Kad Operation";
if(m_pOperator)
{
CKadScript* pKadScript = m_pOperator->GetScript();
ASSERT(pKadScript);
Operation += L" (" + pKadScript->GetName() + L" v" + CKadScript::GetVersion(pKadScript->GetVersion()) + L")";
}
if(Trace.Count() > 0) // remote result
{
wstring Sender = CUInt128(Trace.At((uint32)0)).ToHex();
if(!Error.empty())
LogLine(LOG_DEBUG | Flags, L"%s recived an Error: %s from %s", Operation.c_str(), ErrorMessage.c_str(), Sender.c_str());
else
LogLine(LOG_DEBUG | Flags, L"%s recived a Report: %s from %s", Operation.c_str(), ErrorMessage.c_str(), Sender.c_str());
}
else
{
if(!Error.empty())
LogLine(LOG_DEBUG | Flags, L"%s caused an Error: %s", Operation.c_str(), ErrorMessage.c_str());
else
LogLine(LOG_DEBUG | Flags, L"%s Reports: %s", Operation.c_str(), ErrorMessage.c_str());
}
}
示例3: switch
void SoftwareAuthority::errorData(int err)
{
switch((Q3Socket::Error)err) {
case Q3Socket::ErrConnectionRefused:
LogLine(RDConfig::LogNotice,QString().sprintf(
"Connection to SoftwareAuthority device at %s:%d refused, attempting reconnect",
(const char *)swa_ipaddress.toString(),
swa_ipport));
swa_reconnect_timer->start(SWAUTHORITY_RECONNECT_INTERVAL,true);
break;
case Q3Socket::ErrHostNotFound:
LogLine(RDConfig::LogWarning,QString().sprintf(
"Error on connection to SoftwareAuthority device at %s:%d: Host Not Found",
(const char *)swa_ipaddress.toString(),
swa_ipport));
break;
case Q3Socket::ErrSocketRead:
LogLine(RDConfig::LogWarning,QString().sprintf(
"Error on connection to SoftwareAuthority device at %s:%d: Socket Read Error",
(const char *)swa_ipaddress.toString(),
swa_ipport));
break;
}
}
示例4: LogLine
void Harlond::ProcessResponse(const QString &str)
{
// LogLine(RDConfig::LogNotice,str);
QStringList cmds=cmds.split(" ",str);
if(cmds[0]=="PW") {
if(cmds.size()==2) {
if(cmds[1]=="+") {
LogLine(RDConfig::LogInfo,tr("connection to harlond device at ")+
bt_ip_address.toString()+QString().sprintf(":%d ",bt_tcp_port)+
tr("established"));
bt_socket->writeBlock("SS!",3);
return;
}
}
LogLine(RDConfig::LogInfo,tr("connection to harlond device at ")+
bt_ip_address.toString()+QString().sprintf(":%d ",bt_tcp_port)+
tr("refused, invalid password"));
}
if(cmds[0]=="ON") {
if(cmds.size()==2) {
emit gpiChanged(bt_matrix,cmds[1].toInt()-1,true);
}
}
if(cmds[0]=="OF") {
if(cmds.size()==2) {
emit gpiChanged(bt_matrix,cmds[1].toInt()-1,false);
}
}
}
示例5: SigHandler
void SigHandler(int signo)
{
pid_t pLocalPid;
switch(signo) {
case SIGCHLD:
pLocalPid=waitpid(-1,NULL,WNOHANG);
while(pLocalPid>0) {
pLocalPid=waitpid(-1,NULL,WNOHANG);
}
::signal(SIGCHLD,SigHandler);
::signal(SIGTERM,SigHandler);
::signal(SIGINT,SigHandler);
return;
case SIGTERM:
LogLine(RDConfig::LogInfo,"ripcd exiting normally");
RDDeletePid(RD_PID_DIR,"ripcd.pid");
exit(0);
break;
case SIGINT:
LogLine(RDConfig::LogInfo,"ripcd exiting on SIGINT");
RDDeletePid(RD_PID_DIR,"ripcd.pid");
exit(0);
break;
}
}
示例6: QLocalServer
void CIPCServer::LocalListen(const QString& Name)
{
if(!Name.isEmpty())
{
m_Local = new QLocalServer(this);
if(m_Local->listen(Name))
{
m_Name = Name;
LogLine(LOG_NOTE, tr("Start local server %1").arg(Name));
}
else
{
LogLine(LOG_WARNING, tr("Failed to start local server name %1, selecting alternative name").arg(Name));
QString tmpName = QString("%1_%2").arg(Name).arg(GetRand64());
if(m_Local->listen(tmpName))
{
m_Name = tmpName;
LogLine(LOG_WARNING, tr("Started Local server witn temporary name %1").arg(tmpName));
}
else
LogLine(LOG_ERROR, tr("Failed to start local server!"));
}
connect(m_Local, SIGNAL(newConnection()), this, SLOT(OnLocalConnection()));
}
else
m_Local = NULL;
}
示例7: QTcpServer
void CIPCServer::RemoteListen(quint16 Port)
{
if(Port != 0)
{
m_Remote = new QTcpServer(this);
if(m_Remote->listen(QHostAddress::Any, Port))
{
m_Port = Port;
LogLine(LOG_NOTE, tr("Start remote server on port %1").arg(Port));
}
else
{
LogLine(LOG_WARNING, tr("Failed to start remote server on port %1, selecting alternative port").arg(Port));
quint16 tmpPort = Port + GetRandomInt(1, 1000);
if(m_Remote->listen(QHostAddress::Any, tmpPort))
{
m_Port = tmpPort;
LogLine(LOG_WARNING, tr("Started remote server witn temporary port %1").arg(tmpPort));
}
else
LogLine(LOG_ERROR, tr("Failed to start remote server!"));
}
connect(m_Remote, SIGNAL(newConnection()), this, SLOT(OnRemoteConnection()));
}
else
m_Remote = NULL;
}
示例8: LogLine
void CKadHandler::HandleNodeReq(const CVariant& NodeReq, CKadNode* pNode, CComChannel* pChannel)
{
if(GetParent<CKademlia>()->Cfg()->GetBool("DebugRT"))
LogLine(LOG_DEBUG, L"Recived 'Node Resuest' to %s", pNode->GetID().ToHex().c_str());
CVariant NodeRes;
uint32 uDesiredCount = NodeReq["RCT"];
if(uDesiredCount == 0)
throw CException(LOG_ERROR, L"node requested 0 nodes");
int iMaxState = NodeReq.Get("MNC", NODE_2ND_CLASS);
NodeMap Nodes;
if(!NodeReq.Has("TID"))
GetParent<CKademlia>()->Root()->GetBootstrapNodes(GetParent<CKademlia>()->Root()->GetID(), Nodes, uDesiredCount, pChannel->GetAddress().GetProtocol(), iMaxState);
else
GetParent<CKademlia>()->Root()->GetClosestNodes(NodeReq["TID"], Nodes, uDesiredCount, pChannel->GetAddress().GetProtocol(), iMaxState);
CVariant List;
for(NodeMap::iterator I = Nodes.begin(); I != Nodes.end(); I++)
List.Append(I->second->Store());
NodeRes["LIST"] = List;
if(GetParent<CKademlia>()->Cfg()->GetBool("DebugRT"))
LogLine(LOG_DEBUG, L"Sending 'Node Response' to %s", pNode->GetID().ToHex().c_str());
pChannel->QueuePacket(KAD_NODE_RESPONSE, NodeRes);
}
示例9: TryAssemblyMetadata
bool CTorrent::TryInstallMetadata()
{
if(m_MetadataExchange && m_MetadataExchange->NewData)
{
m_MetadataExchange->NewData = false;
QByteArray Payload = TryAssemblyMetadata();
if(!Payload.isEmpty())
{
if(!m_TorrentInfo->LoadMetadata(Payload))
{
LogLine(LOG_DEBUG | LOG_ERROR, tr("The torrent metadata for %1 (%2) cannot not be parsed.").arg(GetFile()->GetFileName()).arg(QString(m_TorrentInfo->GetInfoHash().toHex())));
// that is not recoverable!!!!
GetFile()->GetInspector()->BlackListHash(GetHash()); // Note: This will delete this
return false;
}
else
{
LogLine(LOG_DEBUG | LOG_SUCCESS, tr("recived metadata for torrent %1 (%2)").arg(GetFile()->GetFileName()).arg(QString(m_TorrentInfo->GetInfoHash().toHex())));
if(!GetFile()->IsPending())
SaveTorrentToFile();
if(!InstallMetadata()) // Note: This can delete this
return false;
emit MetadataLoaded();
}
delete m_MetadataExchange;
m_MetadataExchange = NULL;
return true;
}
}
return true;
}
示例10: UD_ZERO
void CUDTSocketListner::Process()
{
for(;;) // repeat untill all pending connections are accepted
{
/*timeval tv;
tv.tv_sec = 0;
tv.tv_usec = 0;
UDT::UDSET readfds;
UD_ZERO(&readfds);
UD_SET(m_Server, &readfds);
int res = UDT::select(0, &readfds, NULL, NULL, &tv);
if (!((res != UDT::ERROR) && (UD_ISSET(m_Server, &readfds))))
break;*/
sockaddr_in6 sa; // sockaddr_in is smaller
int sa_len = sizeof(sa);
UDTSOCKET Client = UDT::accept(m_Server, (sockaddr*)&sa, &sa_len);
if (UDT::INVALID_SOCK == Client)
{
LogLine(LOG_ERROR, L"accept: %S", UDT::getlasterror().getErrorMessage());
break;
}
else if(Client == NULL)
break;
ConfigSocket(Client);
uint64_t SendKey = 0;
int KeySize = sizeof(SendKey);
UDT::getsockopt(Client, 0, UDT_SENDKEY, &SendKey, &KeySize);
CSafeAddress Address((sockaddr*)&sa, sa_len, sa_len == sizeof(sockaddr_in) ? CSafeAddress::eUDT_IP4 : CSafeAddress::eUDT_IP6);
Address.SetPassKey(SendKey);
GetParent<CSmartSocket>()->AddSessions(Address, new CUDTSocketSession(this, Client, Address));
}
const uint64 Size = 0xFFFF;
char Buffer[Size];
for(;;) // repeat untill all data is read
{
sockaddr_in6 sa; // sockaddr_in is smaller
int sa_len = sizeof(sa);
uint64_t RecvKey = 0;
int Recived = UDT::recvfrom(m_Server, Buffer, Size, (sockaddr*)&sa, &sa_len, &RecvKey);
if (UDT::ERROR == Recived)
{
LogLine(LOG_ERROR, L"recvfrom: %S", UDT::getlasterror().getErrorMessage());
break;
}
else if(Recived == 0)
break; // nothing more to be recived
CBuffer Packet(Buffer, Recived, true);
CSafeAddress Address((sockaddr*)&sa, sa_len, sa_len == sizeof(sockaddr_in) ? CSafeAddress::eUDT_IP4 : CSafeAddress::eUDT_IP6);
Address.SetPassKey(RecvKey);
ReceiveFrom(Packet, Address);
}
}
示例11: CSocketListner
CUDTSocketListner::CUDTSocketListner(CSmartSocket* pSocket, bool bIPv6, uint16 Port)
: CSocketListner(pSocket)
{
if(m_Count++ == 0)
UDT::startup();
m_bIPv6 = bIPv6;
m_Port = 0;
if(m_bIPv6)
{
m_sa = (sockaddr*)new sockaddr_in6;
memset(m_sa, 0, sizeof(sockaddr_in6));
((sockaddr_in6*)m_sa)->sin6_family = AF_INET6;
((sockaddr_in6*)m_sa)->sin6_addr = in6addr_any;
((sockaddr_in6*)m_sa)->sin6_port = htons((u_short)Port);
}
else
{
m_sa = (sockaddr*)new sockaddr_in;
memset(m_sa, 0, sizeof(sockaddr_in));
((sockaddr_in*)m_sa)->sin_family = AF_INET;
((sockaddr_in*)m_sa)->sin_addr.s_addr = INADDR_ANY;
((sockaddr_in*)m_sa)->sin_port = htons((u_short)Port);
}
m_Server = UDT::socket(m_bIPv6 ? AF_INET6 : AF_INET, SOCK_STREAM, IPPROTO_IP);
if(uint64 RecvKey = pSocket->GetRecvKey())
{
UDT::setsockopt(m_Server, 0, UDT_RECVKEY, &RecvKey, sizeof(RecvKey));
bool Obfuscate = true;
UDT::setsockopt(m_Server, 0, UDT_OBFUSCATE, &Obfuscate, sizeof(Obfuscate));
}
bool DirectUDP = true;
UDT::setsockopt(m_Server, 0, UDT_DIRECT, &DirectUDP, sizeof(DirectUDP));
bool reuse_addr = true; // Note: this is true by default anyways
UDT::setsockopt(m_Server, 0, UDT_REUSEADDR, &reuse_addr, sizeof(reuse_addr));
if (UDT::ERROR == UDT::bind(m_Server, m_sa, m_bIPv6 ? sizeof(sockaddr_in6) : sizeof(sockaddr_in)))
{
LogLine(LOG_ERROR, L"bind: %S", UDT::getlasterror().getErrorMessage());
return;
}
if (UDT::ERROR == UDT::listen(m_Server, 1024))
{
LogLine(LOG_ERROR, L"listen: %S", UDT::getlasterror().getErrorMessage());
return;
}
m_Port = Port;
LogLine(LOG_SUCCESS, L"%s Socket is listening at port %d", m_bIPv6 ? L"UDTv6" : L"UDT", m_Port);
bool blockng = false;
UDT::setsockopt(m_Server, 0, UDT_RCVSYN, &blockng, sizeof(blockng));
}
示例12: LogLine
void CKadHandler::HandleRouteReq(const CVariant& RouteReq, CKadNode* pNode, CComChannel* pChannel)
{
if(GetParent<CKademlia>()->Cfg()->GetBool("DebugRU"))
LogLine(LOG_DEBUG, L"Recived 'Route Resuest' from %s", pNode->GetID().ToHex().c_str());
CVariant RouteRes(CVariant::EMap);
SKadData* pData = pChannel->GetData<SKadData>();
CPointer<CKadRelay> pRelay = pData->pLookup->Cast<CKadRelay>();
if(!pRelay)
{
if(!RouteReq.Has("TID")) // this is optional it is not send on a refresn
throw CException(LOG_ERROR, L"Invalid Lookup Request");
if(pData->pLookup)
throw CException(LOG_ERROR, L"Recived Route Resuest for a lookup that is not a CKadRelay");
CLookupManager* pLookupManager = GetParent<CKademlia>()->Manager();
pRelay = pLookupManager->GetRelayEx(RouteReq["EID"], RouteReq["TID"]); // find already existing relay for this Entity and target combination
//ASSERT(pRelay == pLookupManager->GetLookup(RouteReq["LID"])->Cast<CKadRelay>()); // lookup ID should be consistent
if(!pRelay)
{
pRelay = new CKadRelay(RouteReq["TID"], pLookupManager);
if(pRelay->InitRelay(RouteReq)) // if false it means the lookup is invalid
{
pRelay->SetHopLimit(RouteReq.Get("JMPS"));
pRelay->SetJumpCount(RouteReq.Get("HOPS"));
pRelay->SetBrancheCount(RouteReq.Get("BRCH"));
pRelay->SetLookupID(RouteReq["LID"]);
pLookupManager->StartLookup(pRelay.Obj());
if(RouteReq.Has("TRACE"))
pRelay->EnableTrace();
}
}
// For this cahnnel the relay was new, setup BC
pData->pLookup = CPointer<CKadLookup>(pRelay, true); // weak pointer
pChannel->AddUpLimit(pData->pLookup->GetUpLimit());
pChannel->AddDownLimit(pData->pLookup->GetDownLimit());
}
string Error = pRelay->AddDownLink(pNode, pChannel); // add or update
if(!Error.empty())
RouteRes["ERR"] = Error;
if(GetParent<CKademlia>()->Cfg()->GetBool("DebugRU"))
LogLine(LOG_DEBUG, L"Sending 'Route Response' to %s", pNode->GetID().ToHex().c_str());
pChannel->QueuePacket(KAD_ROUTE_RESPONSE, RouteRes);
}
示例13: CVariant
CVariant CKademlia::StartLookup(const CUInt128& TargetID, const CVariant& CodeID, const TCallMap& Execute, const TStoreMap& Store, CPrivateKey* pStoreKey, const TLoadMap& Load
, int Timeout, int HopLimit, int JumpCount, int SpreadCount, bool bTrace, const wstring& Name)
{
if(!m_pKadHandler)
return CVariant();
if(!CodeID.IsValid() && Store.empty() && Load.empty())
{
LogLine(LOG_ERROR, L"Attempted to start an empty Lookup");
return CVariant();
}
CPointer<CKadTask> pLookup = new CKadTask(TargetID, m_pLookupManager);
pLookup->SetName(Name);
if(Timeout != -1)
pLookup->SetTimeOut(Timeout);
if(HopLimit != -1)
pLookup->SetHopLimit(HopLimit);
if(JumpCount != -1)
pLookup->SetJumpCount(JumpCount);
if(SpreadCount != -1)
pLookup->SetSpreadCount(SpreadCount);
if(bTrace)
pLookup->EnableTrace();
if(pStoreKey)
pLookup->SetStoreKey(pStoreKey);
for(TStoreMap::const_iterator I = Store.begin(); I != Store.end(); I++)
pLookup->Store(I->first, I->second.Path, I->second.Data);
for(TLoadMap::const_iterator I = Load.begin(); I != Load.end(); I++)
pLookup->Load(I->first, I->second.Path);
if(CodeID.IsValid())
{
if(!pLookup->SetupScript(CodeID))
{
LogLine(LOG_ERROR, L"Attempted to start a smart lookup with an unavailable script: %s", ToHex(CodeID.GetData(), CodeID.GetSize()).c_str());
return CVariant();
}
for(TCallMap::const_iterator I = Execute.begin(); I != Execute.end(); I++)
pLookup->AddCall(I->second.Function, I->second.Parameters, I->first);
}
CVariant LookupID = m_pLookupManager->StartLookup(pLookup.Obj());
return LookupID;
}
示例14: GetName
void CKadScript::LogReport(UINT Flags, const wstring& ErrorMessage, const string& Error)
{
wstring Operation = L"Kad Script";
Operation += L" (" + GetName() + L" v" + CKadScript::GetVersion(GetVersion()) + L")";
if(!Error.empty())
LogLine(LOG_DEBUG | Flags, L"%s caused an Error: %s", Operation.c_str(), ErrorMessage.c_str());
else
LogLine(LOG_DEBUG | Flags, L"%s Reports: %s", Operation.c_str(), ErrorMessage.c_str());
if(m_pLogger)
m_pLogger->LogReport(Flags, ErrorMessage, Error);
}
示例15: ASSERT
bool CTorrent::LoadTorrentFromFile(const QByteArray& InfoHash)
{
ASSERT(m_TorrentInfo == NULL);
m_TorrentInfo = new CTorrentInfo(this);
ASSERT(m_pHash.isNull());
m_pHash = CFileHashPtr(new CFileHash(HashTorrent));
m_pHash->SetHash(InfoHash);
QString TorrentFile = QString(InfoHash.toHex()) + ".torrent";
if(m_TorrentInfo->LoadTorrentFile(theCore->m_TorrentManager->GetTorrentDir() + TorrentFile))
{
if(m_TorrentInfo->GetInfoHash() == InfoHash)
{
CFile* pFile = GetFile();
if(pFile->GetFileSize() == 0)
pFile->SetFileSize(m_TorrentInfo->GetTotalLength());
LoadPieceHashes();
if(m_TorrentInfo->IsMultiFile() && !pFile->IsMultiFile())
{
CFileHashPtr pMasterHash = pFile->GetMasterHash();
if(!pMasterHash.isNull() && pMasterHash->GetHash() == InfoHash)
{
LogLine(LOG_DEBUG | LOG_ERROR, tr("The multi file %1 is missing its proper index, restoring form torrent").arg(pFile->GetFileName()));
InstallMetadata();
}
}
if(!m_TorrentInfo->IsEmpty() && !pFile->IsComplete() && !pFile->GetPartMap())
SetupPartMap();
}
else
{
LogLine(LOG_DEBUG | LOG_ERROR, tr("The torrent file %1 contains an invalid infohash").arg(TorrentFile));
delete m_TorrentInfo;
m_TorrentInfo = new CTorrentInfo(this);
m_TorrentInfo->SetInfoHash(InfoHash);
}
}
else
m_TorrentInfo->SetInfoHash(InfoHash);
theCore->m_TorrentManager->RegisterInfoHash(m_TorrentInfo->GetInfoHash());
return true; // Note: that is always true even if we fail to load as we always wil be able to proceed one way or another
}