MCPcopy Create free account
hub / github.com/apache/brpc / PrintLog

Function PrintLog

src/butil/logging.cc:975–1000  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

973}
974
975void PrintLog(std::ostream& os, int severity, const char* file, int line,
976 const char* func, const butil::StringPiece& content) {
977 if (!FLAGS_log_as_json) {
978 PrintLogPrefix(os, severity, file, line, func, GetTimestamp());
979 OutputLog(os, content);
980 } else {
981 os << '{';
982 PrintLogPrefixAsJSON(os, severity, file, func, line, GetTimestamp());
983 bool pair_quote = false;
984 if (content.empty() || content[0] != '"') {
985 // not a json, add a 'M' field
986 os << ",\"M\":\"";
987 pair_quote = true;
988 } else {
989 os << ',';
990 }
991 OutputLog(os, content);
992 if (pair_quote) {
993 os << '"';
994 } else if (!content.empty() && content[content.size() -1 ] != '"') {
995 // Controller may write `"M":"...` which misses the last quote
996 os << '"';
997 }
998 os << '}';
999 }
1000}
1001
1002void PrintLog(std::ostream& os,
1003 int severity, const char* file, int line,

Callers 2

LogInfoToLogStrFunction · 0.85
OnLogMessageMethod · 0.85

Calls 6

PrintLogPrefixFunction · 0.85
GetTimestampFunction · 0.85
OutputLogFunction · 0.85
PrintLogPrefixAsJSONFunction · 0.85
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected