28 if (level < LogLevel::INFO) {
30 }
else if (level < LogLevel::WARN) {
32 }
else if (level < LogLevel::ERR) {
34 }
else if (level < LogLevel::CRITICAL) {
36 }
else if (level < LogLevel::DFATAL) {
50 auto timeSinceEpoch = message.
getTimestamp().time_since_epoch();
52 std::chrono::duration_cast<std::chrono::seconds>(timeSinceEpoch);
53 std::chrono::microseconds usecs =
54 std::chrono::duration_cast<std::chrono::microseconds>(timeSinceEpoch) -
56 time_t unixTimestamp = epochSeconds.count();
57 if (!localtime_r(&unixTimestamp, <ime)) {
58 memset(<ime, 0,
sizeof(ltime));
63 "{}{:02d}{:02d} {:02d}:{:02d}:{:02d}.{:06d} {:5d} {}:{}] ",
64 getGlogLevelName(message.
getLevel())[0],
86 size_t headerLengthGuess = 40 + basename.size();
95 header.reserve(headerLengthGuess);
96 headerFormatter.appendTo(header);
102 size_t numLinesGuess = 4;
103 buffer.reserve(((header.size() + 1) * numLinesGuess) + msgData.size());
107 auto end = msgData.find(
'\n', idx);
109 end = msgData.size();
112 buffer.append(header);
113 auto line = msgData.subpiece(idx,
end - idx);
114 buffer.append(line.data(), line.size());
115 buffer.push_back(
'\n');
117 if (
end == msgData.size()) {
123 buffer.reserve(headerLengthGuess + msgData.size());
124 headerFormatter.appendTo(buffer);
125 buffer.append(msgData.data(), msgData.size());
126 buffer.push_back(
'\n');
std::vector< uint8_t > buffer(kBufferSize+16)
—— Concurrent Priority Queue Implementation ——
const std::string & getMessage() const
uint64_t getThreadID() const
LogLevel getLevel() const
auto end(TestAdlIterable &instance)
unsigned int getLineNumber() const
static const size_type npos
folly::StringPiece getFileBaseName() const
Formatter< false, Args... > format(StringPiece fmt, Args &&...args)
std::chrono::system_clock::time_point getTimestamp() const
Range< const char * > StringPiece
bool containsNewlines() const