summaryrefslogtreecommitdiff
path: root/src/third_party/s2
diff options
context:
space:
mode:
authorAndy Schwerin <schwerin@10gen.com>2014-01-14 13:15:49 -0500
committerAndy Schwerin <schwerin@10gen.com>2014-01-22 17:29:28 -0500
commit8af9af8fabd27dcde862e9cc2ccc039142c1ec1a (patch)
tree7edbadec117ab18c80331b73de17b92935648c01 /src/third_party/s2
parent544f130753c04b83397ff156cca873273c7977f2 (diff)
downloadmongo-8af9af8fabd27dcde862e9cc2ccc039142c1ec1a.tar.gz
SERVER-9751 Write log messages from S2 to the mongo logs instead of cout and cerr.
Diffstat (limited to 'src/third_party/s2')
-rwxr-xr-xsrc/third_party/s2/base/logging.cc29
-rwxr-xr-xsrc/third_party/s2/base/logging.h50
2 files changed, 20 insertions, 59 deletions
diff --git a/src/third_party/s2/base/logging.cc b/src/third_party/s2/base/logging.cc
index 45acf2333fa..e8382e9711b 100755
--- a/src/third_party/s2/base/logging.cc
+++ b/src/third_party/s2/base/logging.cc
@@ -11,28 +11,17 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "stdio.h"
-#include "time.h"
-
#include "logging.h"
-namespace google_base {
-DateLogger::DateLogger() {
-#if defined(_MSC_VER)
- _tzset();
-#endif
+#include "mongo/util/assert_util.h"
+#include "mongo/util/mongoutils/str.h"
+
+LogMessageFatal::LogMessageFatal(const char* file, int line) :
+ _lsb(mongo::severe()) {
+ _lsb.setBaseMessage(mongoutils::str::stream() << file << ':' << line << ": ");
}
-char* const DateLogger::HumanDate() {
-#if defined(_MSC_VER)
- _strtime_s(buffer_, sizeof(buffer_));
-#else
- time_t time_value = time(NULL);
- struct tm now;
- localtime_r(&time_value, &now);
- snprintf(buffer_, sizeof(buffer_), "%02d:%02d:%02d",
- now.tm_hour, now.tm_min, now.tm_sec);
-#endif
- return buffer_;
+LogMessageFatal::~LogMessageFatal() {
+ _lsb.~LogstreamBuilder();
+ mongo::fassertFailed(0);
}
-} // namespace google_base
diff --git a/src/third_party/s2/base/logging.h b/src/third_party/s2/base/logging.h
index 28c513227f1..460a8797912 100755
--- a/src/third_party/s2/base/logging.h
+++ b/src/third_party/s2/base/logging.h
@@ -14,12 +14,9 @@
#ifndef BASE_LOGGING_H
#define BASE_LOGGING_H
-#include <stdlib.h>
-#include <stdlib.h>
-#include <iostream>
-using std::ostream;
-using std::cout;
-using std::endl;
+#include <iosfwd>
+
+#include "mongo/util/log.h"
#include "macros.h"
@@ -53,46 +50,21 @@ using std::endl;
#endif
#include "base/port.h"
-#define INFO std::cout
-#define FATAL std::cerr
-#define DFATAL std::cerr
+#define INFO mongo::log().stream()
+#define FATAL LogMessageFatal(__FILE__, __LINE__).stream()
+#define DFATAL LogMessageFatal(__FILE__, __LINE__).stream()
#define S2LOG(x) x
#define VLOG(x) if (x>0) {} else S2LOG(INFO)
-namespace google_base {
-class DateLogger {
- public:
- DateLogger();
- char* const HumanDate();
- private:
- char buffer_[9];
-};
-} // namespace google_base
-
-class LogMessage {
+class LogMessageFatal {
public:
- LogMessage(const char* file, int line) {
- std::cerr << "[" << pretty_date_.HumanDate() << "] "
- << file << ":" << line << ": ";
- }
- ~LogMessage() { std::cerr << "\n"; }
- std::ostream& stream() { return std::cerr; }
+ LogMessageFatal(const char* file, int line);
+ ~LogMessageFatal();
+ std::ostream& stream() { return _lsb.stream(); }
private:
- google_base::DateLogger pretty_date_;
- DISALLOW_COPY_AND_ASSIGN(LogMessage);
-};
-
-class LogMessageFatal : public LogMessage {
- public:
- LogMessageFatal(const char* file, int line)
- : LogMessage(file, line) { }
- ~LogMessageFatal() {
- std::cerr << "\n";
- ::abort();
- }
- private:
+ mongo::logger::LogstreamBuilder _lsb;
DISALLOW_COPY_AND_ASSIGN(LogMessageFatal);
};