本文整理汇总了C++中CStdString::FormatV方法的典型用法代码示例。如果您正苦于以下问题:C++ CStdString::FormatV方法的具体用法?C++ CStdString::FormatV怎么用?C++ CStdString::FormatV使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CStdString
的用法示例。
在下文中一共展示了CStdString::FormatV方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Log
void FLog::Log(FLogLevels logLevel, const char *format, ... ) {
if(!flogFile)
return;
//stop debug messages from being logged, unless compiler is told to log them
#ifndef DEBUGLOG
if(logLevel == FLOG_DEBUG)
return;
#endif
//create formatted string message
CStdString strData;
va_list va;
va_start(va, format);
strData.FormatV(format,va);
va_end(va);
//get log level string name
string levelName = levelNames[logLevel];
//write to file
fputs(levelName.c_str(), flogFile);
fputs(": ", flogFile);
fputs(strData, flogFile);
fputs("\n", flogFile);
//flush write buffer
fflush(flogFile);
}
示例2: libass_log
static void libass_log(int level, const char *fmt, va_list args, void *data)
{
if(level >= 5)
return;
CStdString log;
log.FormatV(fmt, args);
CLog::Log(LOGDEBUG, "CDVDSubtitlesLibass: [ass] %s", log.c_str());
}
示例3: PrintToStdOut
inline void PrintToStdOut(const char *strFormat, ...)
{
CStdString strLog;
va_list argList;
va_start(argList, strFormat);
strLog.FormatV(strFormat, argList);
va_end(argList);
CLockObject lock(g_outputMutex);
cout << strLog << endl;
}
示例4: Log
void ILogger::Log(int loglevel, const char *format, ... )
{
CStdString strData;
strData.reserve(16384);
va_list va;
va_start(va, format);
strData.FormatV(format,va);
va_end(va);
log(loglevel, strData);
}
示例5: DebugLog
void CLog::DebugLog(const char *format, ... )
{
#ifdef _DEBUG
CSingleLock waitLock(critSec);
CStdString strData;
strData.reserve(16384);
va_list va;
va_start(va, format);
strData.FormatV(format, va);
va_end(va);
OutputDebugString(strData.c_str());
if( strData.Right(1) != "\n" )
OutputDebugString("\n");
#endif
}
示例6: AddLog
void CLibCEC::AddLog(const cec_log_level level, const char *strFormat, ...)
{
CStdString strLog;
va_list argList;
va_start(argList, strFormat);
strLog.FormatV(strFormat, argList);
va_end(argList);
CLibCEC *instance = CLibCEC::GetInstance();
if (!instance)
return;
CLockObject lock(instance->m_mutex);
cec_log_message message;
message.level = level;
message.time = GetTimeMs() - instance->m_iStartTime;
snprintf(message.message, sizeof(message.message), "%s", strLog.c_str());
if (instance->m_callbacks)
instance->m_callbacks->CBCecLogMessage(instance->m_cbParam, message);
else
instance->m_logBuffer.Push(message);
}
示例7: Log
void CLog::Log(int loglevel, const char *format, ... )
{
if (g_advancedSettings.m_logLevel > LOG_LEVEL_NORMAL ||
(g_advancedSettings.m_logLevel > LOG_LEVEL_NONE && loglevel >= LOGNOTICE))
{
CSingleLock waitLock(critSec);
if (!fd)
{
// g_stSettings.m_logFolder is initialized in the CSettings constructor to Q:
// and if we are running from DVD, it's changed to T: in CApplication::Create()
CStdString strLogFile, strLogFileOld;
strLogFile.Format("%sxbmc.log", _P(g_stSettings.m_logFolder).c_str());
strLogFileOld.Format("%sxbmc.old.log", _P(g_stSettings.m_logFolder).c_str());
#ifndef _LINUX
::DeleteFile(strLogFileOld.c_str());
::MoveFile(strLogFile.c_str(), strLogFileOld.c_str());
#else
::unlink(strLogFileOld.c_str());
::rename(strLogFile.c_str(), strLogFileOld.c_str());
#endif
#ifndef _LINUX
fd = _fsopen(strLogFile, "a+", _SH_DENYWR);
#else
fd = fopen(strLogFile, "a+");
#endif
}
if (!fd)
return ;
SYSTEMTIME time;
GetLocalTime(&time);
MEMORYSTATUS stat;
GlobalMemoryStatus(&stat);
CStdString strPrefix, strData;
#ifdef __APPLE__
strPrefix.Format("%02.2d:%02.2d:%02.2d T:%lu M:%9ju %7s: ", time.wHour, time.wMinute, time.wSecond, GetCurrentThreadId(), stat.dwAvailPhys, levelNames[loglevel]);
#else
strPrefix.Format("%02.2d:%02.2d:%02.2d T:%lu M:%9u %7s: ", time.wHour, time.wMinute, time.wSecond, GetCurrentThreadId(), stat.dwAvailPhys, levelNames[loglevel]);
#endif
strData.reserve(16384);
va_list va;
va_start(va, format);
strData.FormatV(format,va);
va_end(va);
int length = 0;
while ( length != (int)strData.length() )
{
length = strData.length();
strData.TrimRight(" ");
strData.TrimRight('\n');
strData.TrimRight("\r");
}
#if !defined(_LINUX) && (defined(_DEBUG) || defined(PROFILE))
OutputDebugString(strData.c_str());
OutputDebugString("\n");
#endif
/* fixup newline alignment, number of spaces should equal prefix length */
strData.Replace("\n", "\n ");
strData += "\n";
fwrite(strPrefix.c_str(), strPrefix.size(), 1, fd);
fwrite(strData.c_str(), strData.size(), 1, fd);
fflush(fd);
}
#ifndef _LINUX
#if defined(_DEBUG) || defined(PROFILE)
else
{
// In debug mode dump everything to devstudio regardless of level
CSingleLock waitLock(critSec);
CStdString strData;
strData.reserve(16384);
va_list va;
va_start(va, format);
strData.FormatV(format, va);
va_end(va);
OutputDebugString(strData.c_str());
if( strData.Right(1) != "\n" )
OutputDebugString("\n");
}
#endif
#endif
}
示例8: Log
void CLog::Log(int loglevel, const char *format, ... )
{
if (g_advancedSettings.m_logLevel > LOG_LEVEL_NORMAL ||
(g_advancedSettings.m_logLevel > LOG_LEVEL_NONE && loglevel >= LOGNOTICE))
{
CSingleLock waitLock(critSec);
if (!m_file)
return;
SYSTEMTIME time;
GetLocalTime(&time);
MEMORYSTATUS stat;
GlobalMemoryStatus(&stat);
CStdString strPrefix, strData;
strPrefix.Format("%02.2d:%02.2d:%02.2d T:%"PRIu64" M:%9"PRIu64" %7s: ", time.wHour, time.wMinute, time.wSecond, (uint64_t)CThread::GetCurrentThreadId(), (uint64_t)stat.dwAvailPhys, levelNames[loglevel]);
strData.reserve(16384);
va_list va;
va_start(va, format);
strData.FormatV(format,va);
va_end(va);
if (m_repeatLogLevel == loglevel && *m_repeatLine == strData)
{
m_repeatCount++;
return;
}
else if (m_repeatCount)
{
CStdString strPrefix2, strData2;
strPrefix2.Format("%02.2d:%02.2d:%02.2d T:%"PRIu64" M:%9"PRIu64" %7s: ", time.wHour, time.wMinute, time.wSecond, (uint64_t)CThread::GetCurrentThreadId(), (uint64_t)stat.dwAvailPhys, levelNames[m_repeatLogLevel]);
strData2.Format("Previous line repeats %d times." LINE_ENDING, m_repeatCount);
fwrite(strPrefix2.c_str(),strPrefix2.size(),1,m_file);
fwrite(strData2.c_str(),strData2.size(),1,m_file);
#if !defined(_LINUX) && (defined(_DEBUG) || defined(PROFILE))
OutputDebugString(strData2.c_str());
#endif
m_repeatCount = 0;
}
*m_repeatLine = strData;
m_repeatLogLevel = loglevel;
unsigned int length = 0;
while ( length != strData.length() )
{
length = strData.length();
strData.TrimRight(" ");
strData.TrimRight('\n');
strData.TrimRight("\r");
}
if (!length)
return;
#if !defined(_LINUX) && (defined(_DEBUG) || defined(PROFILE))
OutputDebugString(strData.c_str());
OutputDebugString("\n");
#endif
/* fixup newline alignment, number of spaces should equal prefix length */
strData.Replace("\n", LINE_ENDING" ");
strData += LINE_ENDING;
fwrite(strPrefix.c_str(),strPrefix.size(),1,m_file);
fwrite(strData.c_str(),strData.size(),1,m_file);
fflush(m_file);
}
#ifndef _LINUX
#if defined(_DEBUG) || defined(PROFILE)
else
{
// In debug mode dump everything to devstudio regardless of level
CSingleLock waitLock(critSec);
CStdString strData;
strData.reserve(16384);
va_list va;
va_start(va, format);
strData.FormatV(format, va);
va_end(va);
OutputDebugString(strData.c_str());
if( strData.Right(1) != "\n" )
OutputDebugString("\n");
}
#endif
#endif
}