本文整理汇总了C++中AddDebugLogLineN函数的典型用法代码示例。如果您正苦于以下问题:C++ AddDebugLogLineN函数的具体用法?C++ AddDebugLogLineN怎么用?C++ AddDebugLogLineN使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了AddDebugLogLineN函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: entry
bool CThreadScheduler::DoAddTask(CThreadTask* task, bool overwrite)
{
// GetTick is too lowres, so we just use a counter to ensure that
// the sorted order will match the order in which the tasks were added.
static unsigned taskAge = 0;
// Get the map for this task type, implicitly creating it as needed.
CDescMap& map = m_taskDescs[task->GetType()];
CDescMap::value_type entry(task->GetDesc(), task);
if (map.insert(entry).second) {
AddDebugLogLineN(logThreads, wxT("Task scheduled: ") + task->GetType() + wxT(" - ") + task->GetDesc());
m_tasks.push_back(CEntryPair(task, taskAge++));
m_tasksDirty = true;
} else if (overwrite) {
AddDebugLogLineN(logThreads, wxT("Task overwritten: ") + task->GetType() + wxT(" - ") + task->GetDesc());
CThreadTask* existingTask = map[task->GetDesc()];
if (m_currentTask == existingTask) {
// The duplicate is already being executed, abort it.
m_currentTask->m_abort = true;
} else {
// Task not yet started, simply remove and delete.
wxCHECK2(map.erase(existingTask->GetDesc()), /* Do nothing. */);
delete existingTask;
}
m_tasks.push_back(CEntryPair(task, taskAge++));
map[task->GetDesc()] = task;
m_tasksDirty = true;
} else {
示例2: wxASSERT
bool CAICHHashSet::CreatePartRecoveryData(uint64 nPartStartPos, CFileDataIO* fileDataOut, bool bDbgDontLoad)
{
wxASSERT( m_pOwner );
if (m_pOwner->IsPartFile() || m_eStatus != AICH_HASHSETCOMPLETE) {
wxFAIL;
return false;
}
if (m_pHashTree.m_nDataSize <= EMBLOCKSIZE) {
wxFAIL;
return false;
}
if (!bDbgDontLoad) {
if (!LoadHashSet()) {
AddDebugLogLineN(logSHAHashSet,
CFormat(wxT("Created RecoveryData error: failed to load hashset. File: %s")) % m_pOwner->GetFileName());
SetStatus(AICH_ERROR);
return false;
}
}
bool bResult;
uint8 nLevel = 0;
uint32 nPartSize = min<uint64>(PARTSIZE, m_pOwner->GetFileSize()-nPartStartPos);
m_pHashTree.FindHash(nPartStartPos, nPartSize,&nLevel);
uint16 nHashsToWrite = (nLevel-1) + nPartSize/EMBLOCKSIZE + ((nPartSize % EMBLOCKSIZE != 0 )? 1:0);
const bool bUse32BitIdentifier = m_pOwner->IsLargeFile();
if (bUse32BitIdentifier) {
fileDataOut->WriteUInt16(0); // no 16bit hashs to write
}
fileDataOut->WriteUInt16(nHashsToWrite);
uint64 nCheckFilePos = fileDataOut->GetPosition();
if (m_pHashTree.CreatePartRecoveryData(nPartStartPos, nPartSize, fileDataOut, 0, bUse32BitIdentifier)) {
if (nHashsToWrite*(HASHSIZE+(bUse32BitIdentifier? 4u:2u)) != fileDataOut->GetPosition() - nCheckFilePos) {
wxFAIL;
AddDebugLogLineN( logSHAHashSet,
CFormat(wxT("Created RecoveryData has wrong length. File: %s")) % m_pOwner->GetFileName() );
bResult = false;
SetStatus(AICH_ERROR);
} else {
bResult = true;
}
} else {
AddDebugLogLineN(logSHAHashSet,
CFormat(wxT("Failed to create RecoveryData for '%s'")) % m_pOwner->GetFileName());
bResult = false;
SetStatus(AICH_ERROR);
}
if (!bUse32BitIdentifier) {
fileDataOut->WriteUInt16(0); // no 32bit hashs to write
}
if (!bDbgDontLoad) {
FreeHashSet();
}
return bResult;
}
示例3: AddDebugLogLineN
bool CKnownFileList::Append(CKnownFile *Record, bool afterHashing)
{
if (Record->GetFileSize() > 0) {
const CMD4Hash& tkey = Record->GetFileHash();
CKnownFileMap::iterator it = m_knownFileMap.find(tkey);
if (it == m_knownFileMap.end()) {
m_knownFileMap[tkey] = Record;
return true;
} else {
CKnownFile *existing = it->second;
if (KnownFileMatches(Record, existing->GetFileName(), existing->GetLastChangeDatetime(), existing->GetFileSize())) {
// The file is already on the list, ignore it.
AddDebugLogLineN(logKnownFiles, CFormat(wxT("%s is already on the list")) % Record->GetFileName().GetPrintable());
return false;
} else if (IsOnDuplicates(Record->GetFileName(), Record->GetLastChangeDatetime(), Record->GetFileSize())) {
// The file is on the duplicates list, ignore it.
// Should not happen, at least not after hashing. Or why did it get hashed in the first place then?
AddDebugLogLineN(logKnownFiles, CFormat(wxT("%s is on the duplicates list")) % Record->GetFileName().GetPrintable());
return false;
} else {
if (afterHashing && existing->GetFileSize() == Record->GetFileSize()) {
// We just hashed a "new" shared file and find it's already known under a different name or date.
// Guess what - it was probably renamed or touched.
// So copy over all properties from the existing known file and just keep name/date.
time_t newDate = Record->GetLastChangeDatetime();
CPath newName = Record->GetFileName();
CMemFile f;
existing->WriteToFile(&f);
f.Reset();
Record->LoadFromFile(&f);
Record->SetLastChangeDatetime(newDate);
Record->SetFileName(newName);
}
// The file is a duplicated hash. Add THE OLD ONE to the duplicates list.
// (This is used when reading the known file list where the duplicates are stored in front.)
m_duplicateFileList.push_back(existing);
if (theApp->sharedfiles) {
// Removing the old kad keywords created with the old filename
theApp->sharedfiles->RemoveKeywords(existing);
}
m_knownFileMap[tkey] = Record;
return true;
}
}
} else {
AddDebugLogLineN(logGeneral,
CFormat(wxT("%s is 0-size, not added")) %
Record->GetFileName());
return false;
}
}
示例4: AddDebugLogLineN
// Check all clients that uploaded corrupted data,
// and ban them if they didn't upload enough good data too.
void CCorruptionBlackBox::EvaluateData()
{
CCBBClientMap::iterator it = m_badClients.begin();
for (; it != m_badClients.end(); ++it) {
uint32 ip = it->first;
uint64 bad = it->second.m_downloaded;
if (!bad) {
wxFAIL; // this should not happen
continue;
}
uint64 good = 0;
CCBBClientMap::iterator it2 = m_goodClients.find(ip);
if (it2 != m_goodClients.end()) {
good = it2->second.m_downloaded;
}
int nCorruptPercentage = bad * 100 / (bad + good);
if (nCorruptPercentage > CBB_BANTHRESHOLD) {
CUpDownClient* pEvilClient = theApp->clientlist->FindClientByIP(ip);
wxString clientName;
if (pEvilClient != NULL) {
clientName = pEvilClient->GetClientShortInfo();
AddDebugLogLineN(logPartFile, CFormat(wxT("CorruptionBlackBox(%s): Banning: Found client which sent %d of %d corrupted data, %s"))
% m_partNumber % bad % (good + bad) % pEvilClient->GetClientFullInfo());
theApp->clientlist->AddTrackClient(pEvilClient);
pEvilClient->Ban(); // Identified as sender of corrupt data
// Stop download right away
pEvilClient->SetDownloadState(DS_BANNED);
if (pEvilClient->Disconnected(wxT("Upload of corrupted data"))) {
pEvilClient->Safe_Delete();
}
} else {
clientName = Uint32toStringIP(ip);
theApp->clientlist->AddBannedClient(ip);
}
AddLogLineN(CFormat(_("Banned client %s for sending %s corrupt data of %s total for the file '%s'"))
% clientName % CastItoXBytes(bad) % CastItoXBytes(good + bad) % m_fileName);
} else {
CUpDownClient* pSuspectClient = theApp->clientlist->FindClientByIP(ip);
if (pSuspectClient != NULL) {
AddDebugLogLineN(logPartFile, CFormat(wxT("CorruptionBlackBox(%s): Reporting: Found client which probably sent %d of %d corrupted data, but it is within the acceptable limit, %s"))
% m_partNumber % bad % (good + bad) % pSuspectClient->GetClientFullInfo());
theApp->clientlist->AddTrackClient(pSuspectClient);
} else {
AddDebugLogLineN(logPartFile, CFormat(wxT("CorruptionBlackBox(%s): Reporting: Found client which probably sent %d of %d corrupted data, but it is within the acceptable limit, %s"))
% m_partNumber % bad % (good + bad) % Uint32toStringIP(ip));
}
}
}
}
示例5: AddDebugLogLineN
void CMuleUDPSocket::OnReceive(int errorCode)
{
AddDebugLogLineN(logMuleUDP, CFormat(wxT("Got UDP callback for read: Error %i Socket state %i"))
% errorCode % Ok());
char buffer[UDP_BUFFER_SIZE];
amuleIPV4Address addr;
unsigned length = 0;
bool error = false;
int lastError = 0;
{
wxMutexLocker lock(m_mutex);
if (errorCode || (m_socket == NULL) || !m_socket->IsOk()) {
DestroySocket();
CreateSocket();
return;
}
length = m_socket->RecvFrom(addr, buffer, UDP_BUFFER_SIZE);
lastError = m_socket->LastError();
error = lastError != 0;
}
const uint32 ip = StringIPtoUint32(addr.IPAddress());
const uint16 port = addr.Service();
if (error) {
OnReceiveError(lastError, ip, port);
} else if (length < 2) {
// 2 bytes (protocol and opcode) is the smallets possible packet.
AddDebugLogLineN(logMuleUDP, m_name + wxT(": Invalid Packet received"));
} else if (!ip) {
// wxFAIL;
AddLogLineNS(wxT("Unknown ip receiving a UDP packet! Ignoring: '") + addr.IPAddress() + wxT("'"));
} else if (!port) {
// wxFAIL;
AddLogLineNS(wxT("Unknown port receiving a UDP packet! Ignoring"));
} else if (theApp->clientlist->IsBannedClient(ip)) {
AddDebugLogLineN(logMuleUDP, m_name + wxT(": Dropped packet from banned IP ") + addr.IPAddress());
} else {
AddDebugLogLineN(logMuleUDP, (m_name + wxT(": Packet received ("))
<< addr.IPAddress() << wxT(":") << port << wxT("): ")
<< length << wxT("b"));
OnPacketReceived(ip, port, (byte*)buffer, length);
}
}
示例6: CPath
bool CKnownFileList::Init()
{
CFile file;
CPath fullpath = CPath(theApp->ConfigDir + m_filename);
if (!fullpath.FileExists()) {
// This is perfectly normal. The file was probably either
// deleted, or this is the first time running aMule.
return false;
}
if (!file.Open(fullpath)) {
AddLogLineC(CFormat(_("WARNING: %s cannot be opened.")) % m_filename);
return false;
}
try {
uint8 version = file.ReadUInt8();
if ((version != MET_HEADER) && (version != MET_HEADER_WITH_LARGEFILES)) {
AddLogLineC(_("WARNING: Known file list corrupted, contains invalid header."));
return false;
}
wxMutexLocker sLock(list_mut);
uint32 RecordsNumber = file.ReadUInt32();
AddDebugLogLineN(logKnownFiles, CFormat(wxT("Reading %i known files from file format 0x%2.2x."))
% RecordsNumber % version);
for (uint32 i = 0; i < RecordsNumber; i++) {
CScopedPtr<CKnownFile> record;
if (record->LoadFromFile(&file)) {
AddDebugLogLineN(logKnownFiles,
CFormat(wxT("Known file read: %s")) % record->GetFileName());
Append(record.release());
} else {
AddLogLineC(_("Failed to load entry in known file list, file may be corrupt"));
}
}
AddDebugLogLineN(logKnownFiles, wxT("Finished reading known files"));
return true;
} catch (const CInvalidPacket& e) {
AddLogLineC(_("Invalid entry in known file list, file may be corrupt: ") + e.what());
} catch (const CSafeIOException& e) {
AddLogLineC(CFormat(_("IO error while reading %s file: %s")) % m_filename % e.what());
}
return false;
}
示例7: lock
bool CThreadScheduler::AddTask(CThreadTask* task, bool overwrite)
{
wxMutexLocker lock(s_lock);
// When terminated (on shutdown), all tasks are ignored.
if (s_terminated) {
AddDebugLogLineN(logThreads, wxT("Task discarded: ") + task->GetDesc());
delete task;
return false;
} else if (s_scheduler == NULL) {
s_scheduler = new CThreadScheduler();
AddDebugLogLineN(logThreads, wxT("Scheduler created."));
}
return s_scheduler->DoAddTask(task, overwrite);
}
示例8: wxUINT32_SWAP_ALWAYS
bool CClientList::IncomingBuddy(Kademlia::CContact* contact, Kademlia::CUInt128* buddyID)
{
uint32_t nContactIP = wxUINT32_SWAP_ALWAYS(contact->GetIPAddress());
//If aMule already knows this client, abort this.. It could cause conflicts.
//Although the odds of this happening is very small, it could still happen.
if (FindClientByIP(nContactIP, contact->GetTCPPort())) {
return false;
} else if (IsKadFirewallCheckIP(nContactIP)) { // doing a kad firewall check with this IP, abort
AddDebugLogLineN(logKadMain, wxT("Kad TCP firewallcheck / Buddy request collision for IP ") + Uint32toStringIP(nContactIP));
return false;
}
if (theApp->GetPublicIP() == nContactIP && thePrefs::GetPort() == contact->GetTCPPort()) {
return false; // don't connect ourself
}
//Add client to the lists to be processed.
CUpDownClient* pNewClient = new CUpDownClient(contact->GetTCPPort(), contact->GetIPAddress(), 0, 0, NULL, false, true );
pNewClient->SetKadPort(contact->GetUDPPort());
pNewClient->SetKadState(KS_INCOMING_BUDDY);
byte ID[16];
contact->GetClientID().ToByteArray(ID);
pNewClient->SetUserHash(CMD4Hash(ID));
buddyID->ToByteArray(ID);
pNewClient->SetBuddyID(ID);
AddToKadList(pNewClient);
AddClient(pNewClient);
return true;
}
示例9: TransferredData
// Store a piece of received data (don't know if it's good or bad yet).
// Data is stored in a list for the chunk in belongs to.
void CCorruptionBlackBox::TransferredData(uint64 nStartPos, uint64 nEndPos, uint32 senderIP)
{
if (nStartPos > nEndPos) {
wxFAIL;
return;
}
// convert pos to relative block pos
uint16 nPart = (uint16)(nStartPos / PARTSIZE);
uint32 nRelStartPos = nStartPos - nPart*PARTSIZE;
uint32 nRelEndPos = nEndPos - nPart*PARTSIZE;
if (nRelEndPos >= PARTSIZE) {
// data crosses the partborder, split it
// (for the fun of it, this should never happen)
nRelEndPos = PARTSIZE-1;
TransferredData((nPart+1)*PARTSIZE, nEndPos, senderIP);
}
//
// Let's keep things simple.
// We don't request data we already have.
// We check if received data exceeds block boundaries.
// -> There should not be much overlap here.
// So just stuff everything received into the list and only join adjacent blocks.
//
CRecordList & list = m_Records[nPart]; // this creates the entry if it doesn't exist yet
bool merged = false;
for (CRecordList::iterator it = list.begin(); it != list.end() && !merged; ++it) {
merged = it->Merge(nRelStartPos, nRelEndPos, senderIP);
}
if (!merged) {
list.push_back(CCBBRecord(nRelStartPos, nRelEndPos, senderIP));
AddDebugLogLineN(logPartFile, CFormat(wxT("CorruptionBlackBox(%s): transferred: new record for part %d (%d - %d, %s)"))
% m_partNumber % nPart % nRelStartPos % nRelEndPos % Uint32toStringIP(senderIP));
}
}
示例10: ShutDown
int CamuleDaemonApp::OnExit()
{
#ifdef AMULED28
/*
* Stop all socket threads before entering
* shutdown sequence.
*/
delete listensocket;
listensocket = 0;
if (clientudp) {
delete clientudp;
clientudp = NULL;
}
#endif
ShutDown();
#ifndef __WXMSW__
int ret = sigaction(SIGCHLD, &m_oldSignalChildAction, NULL);
if (ret == -1) {
AddDebugLogLineC(logStandard, CFormat(wxT("CamuleDaemonApp::OnRun(): second sigaction() failed: %m.")));
} else {
AddDebugLogLineN(logGeneral, wxT("CamuleDaemonApp::OnRun(): Uninstallation of SIGCHLD callback with sigaction() succeeded."));
}
#endif // __WXMSW__
// lfroen: delete socket threads
if (ECServerHandler) {
ECServerHandler = 0;
}
delete core_timer;
return CamuleApp::OnExit();
}
示例11: wxCHECK_RET
void CDownloadQueue::AddDownload(CPartFile* file, bool paused, uint8 category)
{
wxCHECK_RET(!IsFileExisting(file->GetFileHash()), wxT("Adding duplicate part-file"));
if (file->GetStatus(true) == PS_ALLOCATING) {
file->PauseFile();
} else if (paused && GetFileCount()) {
file->StopFile();
}
{
wxMutexLocker lock(m_mutex);
m_filelist.push_back( file );
DoSortByPriority();
}
NotifyObservers( EventType( EventType::INSERTED, file ) );
if (category < theApp->glob_prefs->GetCatCount()) {
file->SetCategory(category);
} else {
AddDebugLogLineN( logDownloadQueue, wxT("Tried to add download into invalid category.") );
}
Notify_DownloadCtrlAddFile( file );
theApp->searchlist->UpdateSearchFileByHash(file->GetFileHash()); // Update file in the search dialog if it's still open
AddLogLineC(CFormat(_("Downloading %s")) % file->GetFileName() );
}
示例12: switch
void CHttpStateMachine::process_state(t_sm_state state, bool entry)
{
(this->*m_process_state[state])(entry);
#ifdef __DEBUG__
int n = 0;
switch (state) {
case HTTP_STATE_START:
case HTTP_STATE_END:
case HTTP_STATE_RECEIVE_COMMAND_REPLY:
default:
n = 0;
break;
case HTTP_STATE_SEND_COMMAND_REQUEST:
n = m_packetLenght;
break;
case HTTP_STATE_PROCESS_COMMAND_REPLY:
n = m_lastRead;
break;
}
if (entry) {
DumpMem(m_buffer, n, m_state_name[state], m_ok);
} else {
AddDebugLogLineN(logProxy,
wxString(wxT("wait state -- ")) << m_state_name[state]);
}
#endif // __DEBUG__
}
示例13: CPartFileConvert
void CPartFileConvert::StartThread()
{
if (!s_convertPfThread) {
s_convertPfThread = new CPartFileConvert();
switch ( s_convertPfThread->Create() ) {
case wxTHREAD_NO_ERROR:
AddDebugLogLineN( logPfConvert, wxT("A new thread has been created.") );
break;
case wxTHREAD_RUNNING:
AddDebugLogLineC( logPfConvert, wxT("Error, attempt to create an already running thread!") );
break;
case wxTHREAD_NO_RESOURCE:
AddDebugLogLineC( logPfConvert, wxT("Error, attempt to create a thread without resources!") );
break;
default:
AddDebugLogLineC( logPfConvert, wxT("Error, unknown error attempting to create a thread!") );
}
// The thread shouldn't hog the CPU, as it will already be hogging the HD
s_convertPfThread->SetPriority(WXTHREAD_MIN_PRIORITY);
s_convertPfThread->Run();
}
}
示例14: if
// recursive
// calculates missing hash from the existing ones
// overwrites existing hashs
// fails if no hash is found for any branch
bool CAICHHashTree::ReCalculateHash(CAICHHashAlgo* hashalg, bool bDontReplace)
{
if (m_pLeftTree && m_pRightTree) {
if ( !m_pLeftTree->ReCalculateHash(hashalg, bDontReplace) || !m_pRightTree->ReCalculateHash(hashalg, bDontReplace) ) {
return false;
}
if (bDontReplace && m_bHashValid) {
return true;
}
if (m_pRightTree->m_bHashValid && m_pLeftTree->m_bHashValid) {
hashalg->Reset();
hashalg->Add(m_pLeftTree->m_Hash.GetRawHash(), HASHSIZE);
hashalg->Add(m_pRightTree->m_Hash.GetRawHash(), HASHSIZE);
hashalg->Finish(m_Hash);
m_bHashValid = true;
return true;
} else {
return m_bHashValid;
}
} else if (m_pLeftTree == NULL && m_pRightTree == NULL) {
return true;
} else {
AddDebugLogLineN(logSHAHashSet, wxT("ReCalculateHash failed - Hashtree incomplete"));
return false;
}
}
示例15: OnSignalChildHandler
void OnSignalChildHandler(int /*signal*/, siginfo_t *siginfo, void * /*ucontext*/)
{
// Build the log message
wxString msg;
msg << wxT("OnSignalChildHandler() has been called for child process with pid `") <<
siginfo->si_pid <<
wxT("'. ");
// Make sure we leave no zombies by calling waitpid()
int status = 0;
pid_t result = AmuleWaitPid(siginfo->si_pid, &status, WNOHANG, &msg);
if (result != 1 && result != 0 && (WIFEXITED(status) || WIFSIGNALED(status))) {
// Fetch the wxEndProcessData structure corresponding to this pid
EndProcessDataMap::iterator it = endProcDataMap.find(siginfo->si_pid);
if (it != endProcDataMap.end()) {
wxEndProcessData *endProcData = it->second;
// Remove this entry from the process map
endProcDataMap.erase(siginfo->si_pid);
// Save the exit code for the wxProcess object to read later
endProcData->exitcode = result != -1 && WIFEXITED(status) ?
WEXITSTATUS(status) : -1;
// Make things work as in wxGUI
wxHandleProcessTermination(endProcData);
// wxHandleProcessTermination() will "delete endProcData;"
// So we do not delete it again, ok? Do not uncomment this line.
//delete endProcData;
} else {
msg << wxT(" Error: the child process pid is not on the pid map.");
}
}
// Log our passage here
AddDebugLogLineN(logGeneral, msg);
}