void CLogger::FormatMessage(wxString& string, CSteamID steamID, const char* cszMessage) { wxMutexLocker configLock(m_configLock); wxArrayString tags, replacements; tags.Add(_T("{SteamID}")); replacements.Add(wxString(steamID.SteamRender(), wxConvUTF8)); tags.Add(_T("{MySteamID}")); replacements.Add(wxString(m_pSteamUser->GetSteamID().SteamRender(), wxConvUTF8)); tags.Add(_T("{SteamID64}")); replacements.Add(wxString::Format(_T("%llu"), steamID.ConvertToUint64())); tags.Add(_T("{MySteamID64}")); replacements.Add(wxString::Format(_T("%llu"), m_pSteamUser->GetSteamID().ConvertToUint64())); tags.Add(_T("{Name}")); wxString name = wxString(m_pSteamFriends->GetFriendPersonaName(steamID), wxConvUTF8); const char* cszNickname = NULL; if(m_pClientFriends && m_pGetPlayerNickname) cszNickname = m_pGetPlayerNickname(m_pClientFriends, steamID); if(cszNickname) { name += _T(" (") + wxString(cszNickname, wxConvUTF8) + _T(")"); } replacements.Add(name); tags.Add(_T("{MyName}")); replacements.Add(wxString(m_pSteamFriends->GetPersonaName(), wxConvUTF8)); tags.Add(_T("{Date}")); replacements.Add(wxDateTime::Now().Format(m_dateFormat)); tags.Add(_T("{Time}")); replacements.Add(wxDateTime::Now().Format(m_timeFormat)); tags.Add(_T("{UnixTime}")); replacements.Add(wxString::Format(_T("%lld"), (long long)wxDateTime::GetTimeNow())); tags.Add(_T("{NewLine}")); replacements.Add(_T("\n")); tags.Add(_T("{Tab}")); replacements.Add(_T("\t")); tags.Add(_T("{Message}")); replacements.Add(wxString(cszMessage, wxConvUTF8)); string = TagsReplace(string, tags, replacements); }
void DrillClientConfig::setSocketTimeout(int32_t t){ boost::lock_guard<boost::mutex> configLock(DrillClientConfig::s_mutex); s_socketTimeout=t; }
uint64_t DrillClientConfig::getBufferLimit(){ boost::lock_guard<boost::mutex> configLock(DrillClientConfig::s_mutex); return s_bufferLimit; }
void DrillClientConfig::setBufferLimit(uint64_t l){ boost::lock_guard<boost::mutex> configLock(DrillClientConfig::s_mutex); s_bufferLimit=l; }
void DrillClientConfig::setLogLevel(logLevel_t l){ boost::lock_guard<boost::mutex> configLock(DrillClientConfig::s_mutex); s_logLevel=l; getLogger().m_level=l; //boost::log::core::get()->set_filter(boost::log::trivial::severity >= s_logLevel); }
logLevel_t DrillClientConfig::getLogLevel(){ boost::lock_guard<boost::mutex> configLock(DrillClientConfig::s_mutex); return s_logLevel; }
int32_t DrillClientConfig::getHeartbeatFrequency(){ boost::lock_guard<boost::mutex> configLock(DrillClientConfig::s_mutex); return s_heartbeatFrequency; }
void CLogger::SetLogDirectory(const wxString& path) { wxMutexLocker configLock(m_configLock); m_logDirectory = path; }
int32_t DrillClientConfig::getHandshakeTimeout(){ boost::lock_guard<boost::mutex> configLock(DrillClientConfig::s_mutex); return s_handshakeTimeout; }
void DrillClientConfig::setHeartbeatFrequency(int32_t t){ if (t>0){ boost::lock_guard<boost::mutex> configLock(DrillClientConfig::s_mutex); s_heartbeatFrequency=t; } }
void CLogger::SetTimeFormat(const wxString& format) { wxMutexLocker configLock(m_configLock); m_timeFormat = format; }
void CLogger::SetSeparationString(const wxString& string) { wxMutexLocker configLock(m_configLock); m_separationString = string; }
void CLogger::SetMessageFormat(const wxString& format) { wxMutexLocker configLock(m_configLock); m_messageFormat = format; }
void CLogger::SetReplacementChar(const wxString& c) { wxMutexLocker configLock(m_configLock); m_replacementChar = c; }
void DrillClientConfig::setHandshakeTimeout(int32_t t){ if (t > 0) { boost::lock_guard<boost::mutex> configLock(DrillClientConfig::s_mutex); s_handshakeTimeout = t; } }
int32_t DrillClientConfig::getQueryTimeout(){ boost::lock_guard<boost::mutex> configLock(DrillClientConfig::s_mutex); return s_queryTimeout; }
void DrillClientConfig::setQueryTimeout(int32_t t){ if (t>0){ boost::lock_guard<boost::mutex> configLock(DrillClientConfig::s_mutex); s_queryTimeout=t; } }
void CLogger::FormatFilename(wxString& string, CSteamID steamID) { wxMutexLocker configLock(m_configLock); wxArrayString tags, replacements; tags.Add(_T("{SteamID}")); replacements.Add(wxString(steamID.SteamRender(), wxConvUTF8)); tags.Add(_T("{MySteamID}")); replacements.Add(wxString(m_pSteamUser->GetSteamID().SteamRender(), wxConvUTF8)); tags.Add(_T("{SteamID64}")); replacements.Add(wxString::Format(_T("%llu"), steamID.ConvertToUint64())); tags.Add(_T("{MySteamID64}")); replacements.Add(wxString::Format(_T("%llu"), m_pSteamUser->GetSteamID().ConvertToUint64())); tags.Add(_T("{Name}")); if(steamID.BIndividualAccount()) { replacements.Add(wxString(m_pSteamFriends->GetFriendPersonaName(steamID), wxConvUTF8)); } else { const char* cszChatRoomName = NULL; if(m_pClientFriends && m_pGetChatRoomName) cszChatRoomName = m_pGetChatRoomName(m_pClientFriends, steamID); if(*cszChatRoomName) { replacements.Add(wxString(cszChatRoomName, wxConvUTF8)); } else { wxString name; for(int i = 0; i < m_pSteamFriends->GetFriendCountFromSource(steamID); i++) { name += wxString(m_pSteamFriends->GetFriendPersonaName(m_pSteamFriends->GetFriendFromSourceByIndex(steamID, i)), wxConvUTF8) + _T(" + "); } name.RemoveLast(3); replacements.Add(name); } } tags.Add(_T("{Nickname}")); if(steamID.BIndividualAccount()) { const char* cszNickname = NULL; if(m_pClientFriends && m_pGetPlayerNickname) cszNickname = m_pGetPlayerNickname(m_pClientFriends, steamID); if(cszNickname) { replacements.Add(wxString(cszNickname, wxConvUTF8)); } else { replacements.Add(wxString(m_pSteamFriends->GetFriendPersonaName(steamID), wxConvUTF8)); } } else { replacements.Add(replacements.Last()); } tags.Add(_T("{MyName}")); replacements.Add(wxString(m_pSteamFriends->GetPersonaName(), wxConvUTF8)); tags.Add(_T("{Date}")); replacements.Add(wxDateTime::Now().Format(m_dateFormat)); tags.Add(_T("{Time}")); replacements.Add(wxDateTime::Now().Format(m_timeFormat)); tags.Add(_T("{UnixTime}")); replacements.Add(wxString::Format(_T("%lld"), (long long)wxDateTime::GetTimeNow())); string = TagsReplace(string, tags, replacements); static const wxChar* invalidChars[] = {_T("\\"), _T("/"), _T(":"), _T("*"), _T("?"), _T("\""), _T("<"), _T(">"), _T("|")}; for(int i = 0; i < sizeof(invalidChars) / sizeof(*invalidChars); i++) { string.Replace(invalidChars[i], m_replacementChar); } }