summaryrefslogtreecommitdiff
path: root/src/mongo/logger/log_severity.cpp
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2014-07-16 12:35:13 -0400
committerBenety Goh <benety@mongodb.com>2014-07-29 17:42:21 -0400
commitc91a2c3392fc95be3ed07ba98a4d98b4db754b58 (patch)
tree255115ae0f8391766ca75441b30225f6a4194d34 /src/mongo/logger/log_severity.cpp
parenta0dcb4026b3f1171b4124e2666cf71460d023bb1 (diff)
downloadmongo-c91a2c3392fc95be3ed07ba98a4d98b4db754b58.tar.gz
SERVER-4217 updated detailed log format to include log severity and component name.
Log severity is logged with a single capital letter. F - Severe E - Error W - Warning I - Info and Debug Level 0 D - All debug levels > 0 Component name is logged in upper-case padded with trailing spaces to fit within 8 characters.
Diffstat (limited to 'src/mongo/logger/log_severity.cpp')
-rw-r--r--src/mongo/logger/log_severity.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/mongo/logger/log_severity.cpp b/src/mongo/logger/log_severity.cpp
index ca60f7cdab9..576aab14cee 100644
--- a/src/mongo/logger/log_severity.cpp
+++ b/src/mongo/logger/log_severity.cpp
@@ -59,6 +59,26 @@ namespace {
return StringData(unknownSeverityString, StringData::LiteralTag());
}
+ char LogSeverity::toChar() const {
+ if (_severity > 0)
+ return 'D';
+ // 'S' might be confused with "Success"
+ // Return 'F' to imply Fatal instead.
+ if (*this == LogSeverity::Severe())
+ return 'F';
+ if (*this == LogSeverity::Error())
+ return 'E';
+ if (*this == LogSeverity::Warning())
+ return 'W';
+ if (*this == LogSeverity::Info())
+ return 'I';
+ if (*this == LogSeverity::Log())
+ return 'I';
+ // Should not reach here - returning 'U' for Unknown severity
+ // to be consistent with toStringData().
+ return 'U';
+ }
+
std::ostream& operator<<(std::ostream& os, LogSeverity severity) {
return os << severity.toStringData();
}