本文整理汇总了C++中StringData::endsWith方法的典型用法代码示例。如果您正苦于以下问题:C++ StringData::endsWith方法的具体用法?C++ StringData::endsWith怎么用?C++ StringData::endsWith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringData
的用法示例。
在下文中一共展示了StringData::endsWith方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: attempted
std::ostream& MessageEventDetailsEncoder::encode(const MessageEventEphemeral& event,
std::ostream& os) {
static const size_t maxLogLine = 10 * 1024;
_dateFormatter(os, event.getDate());
os << ' ';
os << event.getSeverity().toChar();
os << ' ';
LogComponent component = event.getComponent();
os << component;
os << ' ';
StringData contextName = event.getContextName();
if (!contextName.empty()) {
os << '[' << contextName << "] ";
}
StringData msg = event.getMessage();
if (msg.size() > maxLogLine) {
os << "warning: log line attempted (" << msg.size() / 1024 << "k) over max size ("
<< maxLogLine / 1024 << "k), printing beginning and end ... ";
os << msg.substr(0, maxLogLine / 3);
os << " .......... ";
os << msg.substr(msg.size() - (maxLogLine / 3));
} else {
os << msg;
}
if (!msg.endsWith(StringData("\n", StringData::LiteralTag())))
os << '\n';
return os;
}
示例2: curTimeString
std::ostream& MessageEventDetailsEncoder::encode(const MessageEventEphemeral& event,
std::ostream &os) {
static const size_t maxLogLine = 10 * 1024;
char dateString[64];
curTimeString(dateString);
os << dateString << ' ';
StringData contextName = event.getContextName();
if (!contextName.empty()) {
os << '[' << contextName << "] ";
}
LogSeverity severity = event.getSeverity();
if (severity >= LogSeverity::Info()) {
os << severity << ": ";
}
StringData msg = event.getMessage();
if (msg.size() > maxLogLine) {
os << "warning: log line attempted (" << msg.size() / 1024 << "k) over max size (" <<
maxLogLine / 1024 << "k), printing beginning and end ... ";
os << msg.substr(0, maxLogLine / 3);
os << " .......... ";
os << msg.substr(msg.size() - (maxLogLine / 3));
}
else {
os << msg;
}
if (!msg.endsWith(StringData("\n", StringData::LiteralTag())))
os << '\n';
return os;
}
示例3:
std::ostream& MessageEventUnadornedEncoder::encode(const MessageEventEphemeral& event,
std::ostream& os) {
StringData message = event.getMessage();
os << message;
if (!message.endsWith("\n"))
os << '\n';
return os;
}
示例4: getMaxLogSizeKB
std::ostream& MessageEventDetailsEncoder::encode(const MessageEventEphemeral& event,
std::ostream& os) {
const auto maxLogSizeKB = getMaxLogSizeKB();
const size_t maxLogSize = maxLogSizeKB * 1024;
getDateFormatter()(os, event.getDate());
os << ' ';
const auto severity = event.getSeverity();
os << severity.toStringDataCompact();
os << ' ';
LogComponent component = event.getComponent();
os << component;
os << ' ';
StringData contextName = event.getContextName();
if (!contextName.empty()) {
os << '[' << contextName << "] ";
}
StringData msg = event.getMessage();
#ifdef _WIN32
// We need to translate embedded Unix style line endings into Windows style endings.
std::string tempstr;
size_t embeddedNewLine = msg.find('\n');
if (embeddedNewLine != std::string::npos) {
tempstr = msg.toString().replace(embeddedNewLine, 1, "\r\n");
embeddedNewLine = tempstr.find('\n', embeddedNewLine + 2);
while (embeddedNewLine != std::string::npos) {
tempstr = tempstr.replace(embeddedNewLine, 1, "\r\n");
embeddedNewLine = tempstr.find('\n', embeddedNewLine + 2);
}
msg = tempstr;
}
#endif
if (event.isTruncatable() && msg.size() > maxLogSize) {
os << "warning: log line attempted (" << msg.size() / 1024 << "kB) over max size ("
<< maxLogSizeKB << "kB), printing beginning and end ... ";
os << msg.substr(0, maxLogSize / 3);
os << " .......... ";
os << msg.substr(msg.size() - (maxLogSize / 3));
} else {
os << msg;
}
if (!msg.endsWith(kEOL))
os << kEOL;
return os;
}