本文整理汇总了C++中LogMessage::Size方法的典型用法代码示例。如果您正苦于以下问题:C++ LogMessage::Size方法的具体用法?C++ LogMessage::Size怎么用?C++ LogMessage::Size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LogMessage
的用法示例。
在下文中一共展示了LogMessage::Size方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _write
void AppenderFile::_write(LogMessage const& message)
{
bool exceedMaxSize = maxFileSize > 0 && (fileSize.value() + message.Size()) > maxFileSize;
if (dynamicName)
{
char namebuf[TRINITY_PATH_MAX];
snprintf(namebuf, TRINITY_PATH_MAX, filename.c_str(), message.param1.c_str());
// always use "a" with dynamic name otherwise it could delete the log we wrote in last _write() call
FILE* file = OpenFile(namebuf, "a", backup || exceedMaxSize);
if (!file)
return;
fprintf(file, "%s%s", message.prefix.c_str(), message.text.c_str());
fflush(file);
fileSize += uint64(message.Size());
fclose(file);
return;
}
else if (exceedMaxSize)
logfile = OpenFile(filename, "w", true);
if (!logfile)
return;
fprintf(logfile, "%s%s", message.prefix.c_str(), message.text.c_str());
fflush(logfile);
fileSize += uint64(message.Size());
}
示例2: _write
void AppenderFile::_write(LogMessage const& message)
{
bool exceedMaxSize = maxFileSize > 0 && (fileSize.value() + message.Size()) > maxFileSize;
if (dynamicName)
{
char namebuf[TRINITY_PATH_MAX];
snprintf(namebuf, TRINITY_PATH_MAX, filename.c_str(), message.param1.c_str());
logfile = OpenFile(namebuf, mode, backup || exceedMaxSize);
}
else if (exceedMaxSize)
logfile = OpenFile(filename, "w", true);
if (!logfile)
return;
fprintf(logfile, "%s%s", message.prefix.c_str(), message.text.c_str());
fflush(logfile);
fileSize += uint64(message.Size());
if (dynamicName)
CloseFile();
}